# HG changeset patch # User Pierre-Yves David # Date 1435167475 18000 # Node ID 7125225a5287b833a20aba192f9c888df228c09d # Parent 7fdd1782fc4ee9da87d8af13e806dc9055db2c38 ancestors: prefetch method outside of the loop 15412bba5a68 is yet another example where this is worthwhile when it comes to performance, we blindly do it for all 'lazyancestors' methods. diff -r 7fdd1782fc4e -r 7125225a5287 mercurial/ancestor.py --- a/mercurial/ancestor.py Sun Sep 28 20:18:43 2014 -0700 +++ b/mercurial/ancestor.py Wed Jun 24 12:37:55 2015 -0500 @@ -316,11 +316,14 @@ stoprev = self._stoprev visit = collections.deque(revs) + see = seen.add + schedule = visit.append + while visit: for parent in parentrevs(visit.popleft()): if parent >= stoprev and parent not in seen: - visit.append(parent) - seen.add(parent) + schedule(parent) + see(parent) yield parent def __contains__(self, target): @@ -337,6 +340,7 @@ stoprev = self._stoprev heappop = heapq.heappop heappush = heapq.heappush + see = seen.add targetseen = False @@ -347,7 +351,7 @@ # We need to make sure we push all parents into the heap so # that we leave it in a consistent state for future calls. heappush(visit, -parent) - seen.add(parent) + see(parent) if parent == target: targetseen = True