Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revsetlang.py @ 38625:52f19a840543
revset: add optimization for heads(commonancestors())
Previously, the only way to get these commits were (tested on
mozilla-central):
hg perfrevset 'heads(::a7cf55 and ::d8b15)'
! wall 4.988366 comb 4.960000 user 4.780000 sys 0.180000 (best of 3)
After this patch:
(python)
hg perfrevset 'heads(commonancestors(a7cf55 + d8b15))'
! wall 0.002155 comb 0.000000 user 0.000000 sys 0.000000 (best of 1107)
(C)
hg perfrevset 'heads(commonancestors(a7cf55 + d8b15))'
! wall 0.000568 comb 0.000000 user 0.000000 sys 0.000000 (best of 4646)
author | Sean Farley <sean@farley.io> |
---|---|
date | Tue, 26 Jun 2018 15:26:21 -0700 |
parents | 03d7f885d5f2 |
children | e7aa113b14f7 |
comparison
equal
deleted
inserted
replaced
38624:5460926352ee | 38625:52f19a840543 |
---|---|
457 return w, (op, x[1], t) | 457 return w, (op, x[1], t) |
458 elif op == 'func': | 458 elif op == 'func': |
459 f = getsymbol(x[1]) | 459 f = getsymbol(x[1]) |
460 wa, ta = _optimize(x[2]) | 460 wa, ta = _optimize(x[2]) |
461 w = getattr(symbols.get(f), '_weight', 1) | 461 w = getattr(symbols.get(f), '_weight', 1) |
462 m = _match('commonancestors(_)', ta) | |
463 | |
464 # Optimize heads(commonancestors(_)) because we have a fast version | |
465 if f == 'heads' and m: | |
466 return w + wa, _build('_commonancestorheads(_)', m[1]) | |
467 | |
462 return w + wa, (op, x[1], ta) | 468 return w + wa, (op, x[1], ta) |
463 raise ValueError('invalid operator %r' % op) | 469 raise ValueError('invalid operator %r' % op) |
464 | 470 |
465 def optimize(tree): | 471 def optimize(tree): |
466 """Optimize evaluatable tree | 472 """Optimize evaluatable tree |