changeset 21986:48166e46f111

locate: use ctx.matches instead of ctx.walk On mozilla-central, which is around 100,000 files, best of 5: $ hg --time locate > /dev/null before: real 1.460 secs (user 1.140+0.000 sys 0.320+0.000) after: real 0.620 secs (user 0.610+0.000 sys 0.020+0.000) $ hg --time locate README > /dev/null before: real 0.630 secs (user 0.330+0.000 sys 0.290+0.000) after: real 0.120 secs (user 0.110+0.000 sys 0.020+0.000) Larger repositories see correspondingly larger performance gains.
author Siddharth Agarwal <sid0@fb.com>
date Fri, 01 Aug 2014 22:16:54 -0700
parents 7e871e771300
children 4953cd193e84
files mercurial/commands.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Aug 01 22:07:29 2014 -0700
+++ b/mercurial/commands.py	Fri Aug 01 22:16:54 2014 -0700
@@ -4040,11 +4040,11 @@
     rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
 
     ret = 1
-    m = scmutil.match(repo[rev], pats, opts, default='relglob')
+    ctx = repo[rev]
+    m = scmutil.match(ctx, pats, opts, default='relglob')
     m.bad = lambda x, y: False
-    for abs in repo[rev].walk(m):
-        if not rev and abs not in repo.dirstate:
-            continue
+
+    for abs in ctx.matches(m):
         if opts.get('fullpath'):
             ui.write(repo.wjoin(abs), end)
         else: