Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 23115:c23c03605c59 stable
revset: don't recreate matcher for every revision
The matcher variable 'm' in checkstatus() is reset to None on each
call, so the caching of the matcher no longer happens as it was
intended. This seems to be a regression in ed7b674824a3 (revset: added
lazyset implementation to checkstatus, 2014-01-03).
Fix by moving the cached matcher into the enclosing function so it's
actually cached across calls. This speeds up
hg log -r 'modifies(mercurial/context.py)' >/dev/null
from 7.5s to 4s.
Also see similar fix in f2aeff8a87b6 (revset: avoid recalculating
filesets, 2014-10-22).
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 31 Oct 2014 10:41:36 -0700 |
parents | ac494b087feb |
children | 7361d8244efb |
comparison
equal
deleted
inserted
replaced
23114:0b7853f969ac | 23115:c23c03605c59 |
---|---|
524 return subset & bundlerevs | 524 return subset & bundlerevs |
525 | 525 |
526 def checkstatus(repo, subset, pat, field): | 526 def checkstatus(repo, subset, pat, field): |
527 hasset = matchmod.patkind(pat) == 'set' | 527 hasset = matchmod.patkind(pat) == 'set' |
528 | 528 |
529 mcache = [None] | |
529 def matches(x): | 530 def matches(x): |
530 m = None | 531 c = repo[x] |
532 if not mcache[0] or hasset: | |
533 mcache[0] = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
534 m = mcache[0] | |
531 fname = None | 535 fname = None |
532 c = repo[x] | 536 if not m.anypats() and len(m.files()) == 1: |
533 if not m or hasset: | 537 fname = m.files()[0] |
534 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
535 if not m.anypats() and len(m.files()) == 1: | |
536 fname = m.files()[0] | |
537 if fname is not None: | 538 if fname is not None: |
538 if fname not in c.files(): | 539 if fname not in c.files(): |
539 return False | 540 return False |
540 else: | 541 else: |
541 for f in c.files(): | 542 for f in c.files(): |