##// END OF EJS Templates
ancestors: prefetch method outside of the loop...
Pierre-Yves David -
r25639:7125225a default
parent child Browse files
Show More
@@ -316,11 +316,14 b' class lazyancestors(object):'
316 stoprev = self._stoprev
316 stoprev = self._stoprev
317 visit = collections.deque(revs)
317 visit = collections.deque(revs)
318
318
319 see = seen.add
320 schedule = visit.append
321
319 while visit:
322 while visit:
320 for parent in parentrevs(visit.popleft()):
323 for parent in parentrevs(visit.popleft()):
321 if parent >= stoprev and parent not in seen:
324 if parent >= stoprev and parent not in seen:
322 visit.append(parent)
325 schedule(parent)
323 seen.add(parent)
326 see(parent)
324 yield parent
327 yield parent
325
328
326 def __contains__(self, target):
329 def __contains__(self, target):
@@ -337,6 +340,7 b' class lazyancestors(object):'
337 stoprev = self._stoprev
340 stoprev = self._stoprev
338 heappop = heapq.heappop
341 heappop = heapq.heappop
339 heappush = heapq.heappush
342 heappush = heapq.heappush
343 see = seen.add
340
344
341 targetseen = False
345 targetseen = False
342
346
@@ -347,7 +351,7 b' class lazyancestors(object):'
347 # We need to make sure we push all parents into the heap so
351 # We need to make sure we push all parents into the heap so
348 # that we leave it in a consistent state for future calls.
352 # that we leave it in a consistent state for future calls.
349 heappush(visit, -parent)
353 heappush(visit, -parent)
350 seen.add(parent)
354 see(parent)
351 if parent == target:
355 if parent == target:
352 targetseen = True
356 targetseen = True
353
357
General Comments 0
You need to be logged in to leave comments. Login now