bisect: stop early if we find a perfect candidate
authorMatt Mackall <mpm@selenic.com>
Mon, 31 Dec 2007 18:20:34 -0600
changeset 5771 9d3f49f52a4a
parent 5770 f5b858fc8067
child 5772 4c46636eafe5
bisect: stop early if we find a perfect candidate
hgext/hbisect.py
--- a/hgext/hbisect.py	Mon Dec 31 18:20:34 2007 -0600
+++ b/hgext/hbisect.py	Mon Dec 31 18:20:34 2007 -0600
@@ -53,6 +53,7 @@
     tot = len(candidates)
     if tot == 1:
         return (bad, 0)
+    perfect = tot / 2
 
     # find the best node to test
     best_rev = None
@@ -84,6 +85,8 @@
             if value > best_len:
                 best_len = value
                 best_rev = rev
+                if value == perfect: # found a perfect candidate? quit early
+                    break
 
     assert best_rev is not None
     best_node = changelog.node(best_rev)