revset-phases: prefetch attributes in phasesrelated revsets
Pre-fetching attributes gives a significant performance boost. Such is Python.
draft()
0) wall 0.011661 comb 0.010000 user 0.010000 sys 0.000000 (best of 205)
1) wall 0.009804 comb 0.000000 user 0.000000 sys 0.000000 (best of 231)
draft() - ::bookmark()
0) wall 0.014173 comb 0.010000 user 0.010000 sys 0.000000 (best of 177)
1) wall 0.012966 comb 0.010000 user 0.010000 sys 0.000000 (best of 182)
--- a/mercurial/revset.py Sat Oct 11 01:21:47 2014 -0700
+++ b/mercurial/revset.py Thu Oct 16 17:46:58 2014 -0700
@@ -743,8 +743,9 @@
Changeset in draft phase."""
# i18n: "draft" is a keyword
getargs(x, 0, 0, _("draft takes no arguments"))
- pc = repo._phasecache
- condition = lambda r: pc.phase(repo, r) == phases.draft
+ phase = repo._phasecache.phase
+ target = phases.draft
+ condition = lambda r: phase(repo, r) == target
return subset.filter(condition, cache=False)
def extinct(repo, subset, x):
@@ -1294,8 +1295,9 @@
Changeset in public phase."""
# i18n: "public" is a keyword
getargs(x, 0, 0, _("public takes no arguments"))
- pc = repo._phasecache
- condition = lambda r: pc.phase(repo, r) == phases.public
+ phase = repo._phasecache.phase
+ target = phases.public
+ condition = lambda r: phase(repo, r) == target
return subset.filter(condition, cache=False)
def remote(repo, subset, x):
@@ -1493,8 +1495,9 @@
Changeset in secret phase."""
# i18n: "secret" is a keyword
getargs(x, 0, 0, _("secret takes no arguments"))
- pc = repo._phasecache
- condition = lambda x: pc.phase(repo, x) == phases.secret
+ phase = repo._phasecache.phase
+ target = phases.secret
+ condition = lambda r: phase(repo, r) == target
return subset.filter(condition, cache=False)
def sort(repo, subset, x):