From patchwork Tue Feb 11 18:50:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,4] revset: added lazyset implementation to keyword revset From: Lucas Moscovicz X-Patchwork-Id: 3572 Message-Id: <9e46d74473bc91834157.1392144652@dev1037.prn2.facebook.com> To: mercurial-devel@selenic.com Date: Tue, 11 Feb 2014 10:50:52 -0800 # HG changeset patch # User Lucas Moscovicz # Date 1391015043 28800 # Wed Jan 29 09:04:03 2014 -0800 # Node ID 9e46d74473bc918341572a5b94737a20b56e01b1 # Parent 6a54b66aa4d1acaa02bb1292d4432cc37bdd6266 revset: added lazyset implementation to keyword revset Performance benchmarking: $ time hg log -qr "first(keyword(changeset))" 0:9117c6561b0b real 0m3.466s user 0m3.345s sys 0m0.072s $ time ./hg log -qr "first(keyword(changeset))" 0:9117c6561b0b real 0m0.365s user 0m0.199s sys 0m0.083s diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -921,13 +921,13 @@ """ # i18n: "keyword" is a keyword kw = encoding.lower(getstring(x, _("keyword requires a string"))) - l = [] - for r in subset: + + def matches(r): c = repo[r] - if util.any(kw in encoding.lower(t) - for t in c.files() + [c.user(), c.description()]): - l.append(r) - return baseset(l) + return util.any(kw in encoding.lower(t) for t in c.files() + [c.user(), + c.description()]) + + return lazyset(subset, matches) def limit(repo, subset, x): """``limit(set, [n])``