ancestor: return early from _lazyancestorsiter() when reached to stoprev
authorYuya Nishihara <yuya@tcha.org>
Mon, 10 Sep 2018 21:46:19 +0900
changeset 39534 fd9029d36c41
parent 39533 f6bcb4f9cd3c
child 39535 b9ee9c2e10dd
ancestor: return early from _lazyancestorsiter() when reached to stoprev There's no need to empty the heap.
mercurial/ancestor.py
--- a/mercurial/ancestor.py	Tue Sep 11 22:38:32 2018 +0900
+++ b/mercurial/ancestor.py	Mon Sep 10 21:46:19 2018 +0900
@@ -281,12 +281,13 @@
 
     while visit:
         current = -nextitem(visit)
-        if current >= stoprev:
-            yield current
-            for parent in parentrevs(current):
-                if parent not in seen:
-                    schedule(visit, -parent)
-                    see(parent)
+        if current < stoprev:
+            break
+        yield current
+        for parent in parentrevs(current):
+            if parent not in seen:
+                schedule(visit, -parent)
+                see(parent)
 
 class lazyancestors(object):
     def __init__(self, pfunc, revs, stoprev=0, inclusive=False):