revset: added lazyset implementation to desc revset
Performance benchmarking:
$ time hg log -qr "first(desc(hg))"
changeset: 0:
9117c6561b0b
real 0m2.210s
user 0m2.158s
sys 0m0.049s
$ time ./hg log -qr "first(desc(hg))"
changeset: 0:
9117c6561b0b
real 0m0.171s
user 0m0.131s
sys 0m0.035s
--- a/mercurial/revset.py Mon Feb 03 16:15:25 2014 -0800
+++ b/mercurial/revset.py Thu Jan 30 15:39:56 2014 -0800
@@ -590,12 +590,12 @@
"""
# i18n: "desc" is a keyword
ds = encoding.lower(getstring(x, _("desc requires a string")))
- l = []
- for r in subset:
- c = repo[r]
- if ds in encoding.lower(c.description()):
- l.append(r)
- return baseset(l)
+
+ def matches(x):
+ c = repo[x]
+ return ds in encoding.lower(c.description())
+
+ return lazyset(subset, matches)
def _descendants(repo, subset, x, followfirst=False):
args = getset(repo, baseset(repo), x)