Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 18063:34a1a639d835
revset.children: ignore rev numbers that are too low
This replaces unnecessary parentrevs() calls with calculating min(parentset).
Even though the min operation is O(size of parentset), since parentrevs is
relatively expensive, this tradeoff almost always works in our favour. In a
repository with over 400,000 changesets, hg perfrevset "children(X)" takes:
Set X Before After
-1 0.51s 0.06s
-1000: 0.55s 0.08s
-10000: 0.56s 0.10s
-100000: 0.60s 0.25s
-100000:-99000 0.55s 0.19s
0:100000 0.60s 0.61s
all() 0.72s 0.74s
The relative performance is similar for Mercurial's own repository -- several
times faster in most cases, slightly slower for revisions close to 0 and
all().
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 07 Dec 2012 10:37:43 -0800 |
parents | 83aa4359c49f |
children | bea754715961 |
comparison
equal
deleted
inserted
replaced
18062:1471f5e83686 | 18063:34a1a639d835 |
---|---|
486 break | 486 break |
487 return s | 487 return s |
488 | 488 |
489 def _children(repo, narrow, parentset): | 489 def _children(repo, narrow, parentset): |
490 cs = set() | 490 cs = set() |
491 if not parentset: | |
492 return cs | |
491 pr = repo.changelog.parentrevs | 493 pr = repo.changelog.parentrevs |
494 minrev = min(parentset) | |
492 for r in narrow: | 495 for r in narrow: |
496 if r <= minrev: | |
497 continue | |
493 for p in pr(r): | 498 for p in pr(r): |
494 if p in parentset: | 499 if p in parentset: |
495 cs.add(r) | 500 cs.add(r) |
496 return cs | 501 return cs |
497 | 502 |