viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Tweaks to binary search for reverse search, a=chris

Chris Pollett [2019-12-29 16:Dec:th]
Tweaks to binary search for reverse search, a=chris
Filename
src/library/IndexShard.php
diff --git a/src/library/IndexShard.php b/src/library/IndexShard.php
index 97803f719..fc5851e26 100644
--- a/src/library/IndexShard.php
+++ b/src/library/IndexShard.php
@@ -1164,17 +1164,16 @@ class IndexShard extends PersistentStructure implements CrawlConstants
                             $current++;
                             $low = $current;
                         }
-                        $current = (($low + $high) >> 1);
                     }
                 } else if ($doc_index < $post_doc_index) {
                     if ($low == $current) {
                         return [$current << 2, $post_doc_index << 4];
                     }
                     $high = $current;
-                    $current = (($low + $high) >> 1);
                 } else  {
                     return [$current << 2, $post_doc_index << 4];
                 }
+                $current = (($low + $high) >> 1);
             } while($current <= $end);
         } else {
             do {
@@ -1188,17 +1187,17 @@ class IndexShard extends PersistentStructure implements CrawlConstants
                             $current--;
                             $high = $current;
                         }
-                        $current = (($low + $high) >> 1);
                     }
                 } else if ($doc_index > $post_doc_index) {
                     if ($high == $current) {
                         return [$current << 2, $post_doc_index << 4];
                     }
                     $low = $current;
-                    $current = (($low + $high) >> 1);
                 } else  {
                     return [$current << 2, $post_doc_index << 4];
                 }
+                //round up for reverse binary search
+                $current = (($low + $high + 1) >> 1);
             } while($current >= $start);
         }
         return false;
ViewGit