diff utils.c @ 5799:821155aecf2a libavformat

Add special case to avoid binary search when appending index entries.
author michael
date Tue, 09 Mar 2010 15:19:23 +0000
parents 2e42bb81d80b
children f4ca0041b4f4
line wrap: on
line diff
--- a/utils.c	Tue Mar 09 14:59:40 2010 +0000
+++ b/utils.c	Tue Mar 09 15:19:23 2010 +0000
@@ -1305,6 +1305,10 @@
     a = - 1;
     b = nb_entries;
 
+    //optimize appending index entries at the end
+    if(b && entries[b-1].timestamp < wanted_timestamp)
+        a= b-1;
+
     while (b - a > 1) {
         m = (a + b) >> 1;
         timestamp = entries[m].timestamp;