Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 20073:eeba4eaf0716
revlog: return lazy set from findcommonmissing
When computing the commonmissing, it greedily computes the entire set
immediately. On a large repo where the majority of history is irrelevant, this
causes a significant slow down.
Replacing it with a lazy set makes amend go from 11 seconds to 8.7 seconds.
author | Durham Goode <durham@fb.com> |
---|---|
date | Mon, 11 Nov 2013 16:40:02 -0800 |
parents | a9e92b11a3f2 |
children | 5fc2ae1c631b |
comparison
equal
deleted
inserted
replaced
20072:6d4fda48b4e3 | 20073:eeba4eaf0716 |
---|---|
399 | 399 |
400 common = [self.rev(n) for n in common] | 400 common = [self.rev(n) for n in common] |
401 heads = [self.rev(n) for n in heads] | 401 heads = [self.rev(n) for n in heads] |
402 | 402 |
403 # we want the ancestors, but inclusive | 403 # we want the ancestors, but inclusive |
404 has = set(self.ancestors(common)) | 404 class lazyset(object): |
405 def __init__(self, lazyvalues): | |
406 self.addedvalues = set() | |
407 self.lazyvalues = lazyvalues | |
408 | |
409 def __contains__(self, value): | |
410 return value in self.addedvalues or value in self.lazyvalues | |
411 | |
412 def __iter__(self): | |
413 added = self.addedvalues | |
414 for r in added: | |
415 yield r | |
416 for r in self.lazyvalues: | |
417 if not r in added: | |
418 yield r | |
419 | |
420 def add(self, value): | |
421 self.addedvalues.add(value) | |
422 | |
423 def update(self, values): | |
424 self.addedvalues.update(values) | |
425 | |
426 has = lazyset(self.ancestors(common)) | |
405 has.add(nullrev) | 427 has.add(nullrev) |
406 has.update(common) | 428 has.update(common) |
407 | 429 |
408 # take all ancestors from heads that aren't in has | 430 # take all ancestors from heads that aren't in has |
409 missing = set() | 431 missing = set() |