changeset 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 2af44abfbfe8
children 4410bccf6a8a
files utils.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
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;