Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 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 | f4e5753745e9 |
children | a5bb0c4001ae |
comparison
equal
deleted
inserted
replaced
21985:7e871e771300 | 21986:48166e46f111 |
---|---|
4038 """ | 4038 """ |
4039 end = opts.get('print0') and '\0' or '\n' | 4039 end = opts.get('print0') and '\0' or '\n' |
4040 rev = scmutil.revsingle(repo, opts.get('rev'), None).node() | 4040 rev = scmutil.revsingle(repo, opts.get('rev'), None).node() |
4041 | 4041 |
4042 ret = 1 | 4042 ret = 1 |
4043 m = scmutil.match(repo[rev], pats, opts, default='relglob') | 4043 ctx = repo[rev] |
4044 m = scmutil.match(ctx, pats, opts, default='relglob') | |
4044 m.bad = lambda x, y: False | 4045 m.bad = lambda x, y: False |
4045 for abs in repo[rev].walk(m): | 4046 |
4046 if not rev and abs not in repo.dirstate: | 4047 for abs in ctx.matches(m): |
4047 continue | |
4048 if opts.get('fullpath'): | 4048 if opts.get('fullpath'): |
4049 ui.write(repo.wjoin(abs), end) | 4049 ui.write(repo.wjoin(abs), end) |
4050 else: | 4050 else: |
4051 ui.write(((pats and m.rel(abs)) or abs), end) | 4051 ui.write(((pats and m.rel(abs)) or abs), end) |
4052 ret = 0 | 4052 ret = 0 |