Patchwork [3,of,6] revset: avoid loop for "match.files()" having always one element for efficiency

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Jan. 17, 2014, 2:57 p.m.
Message ID <2a4c78d82827918ffbb7.1389970625@juju>
Download mbox | patch
Permalink /patch/3367/
State Accepted
Commit f3cef19befb10fc88adbdfa0f86c704814809373
Headers show

Comments

Katsunori FUJIWARA - Jan. 17, 2014, 2:57 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1389969732 -32400
#      Fri Jan 17 23:42:12 2014 +0900
# Node ID 2a4c78d82827918ffbb7109c75e083cfdb260616
# Parent  fbeb931aa253e163ebfd44f7859f97aae7a398bf
revset: avoid loop for "match.files()" having always one element for efficiency

This patch avoids the loop for "match.files()" having always one
element in revset predicate "filelog()" for efficiency: "match" object
"m" is constructed with "[pat]" as "patterns" argument.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -722,10 +722,10 @@ 
     s = set()
 
     if not matchmod.patkind(pat):
-        for f in m.files():
-            fl = repo.file(f)
-            for fr in fl:
-                s.add(fl.linkrev(fr))
+        f = m.files()[0]
+        fl = repo.file(f)
+        for fr in fl:
+            s.add(fl.linkrev(fr))
     else:
         for f in repo[None]:
             if m(f):