changeset 20837:191a0ae37767

grep: use "found" instead of "filerevmatches" examination for efficiency Before this patch, internal function "display()" of "hg grep" stores whether matching is already found or not into the dictionary "filerevmatches" by "(fn, rev)" tuple as the key. But this is redundant, because: - "filerevmatches" is local variable of "display()", so each "display()" invocations don't affect others - both "fn" and "rev" (gotten from "ctx" argument) are never changed in each "display()" invocations Then, "filerevmatches" should have only one entry at most, and "(fn, rev) in filerevmatches" should be equal to "found". This patch uses "found" instead of "filerevmatches" examination for efficiency.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 15 Feb 2014 19:54:05 +0900
parents a8b4541bb961
children fe849868fc5a
files mercurial/commands.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Feb 15 19:52:36 2014 +0900
+++ b/mercurial/commands.py	Sat Feb 15 19:54:05 2014 +0900
@@ -3343,7 +3343,6 @@
         rev = ctx.rev()
         datefunc = ui.quiet and util.shortdate or util.datestr
         found = False
-        filerevmatches = {}
         @util.cachefunc
         def binary():
             flog = getfile(fn)
@@ -3366,10 +3365,8 @@
             if opts.get('date'):
                 cols.append((datefunc(ctx.date()), 'grep.date'))
             if opts.get('files_with_matches'):
-                c = (fn, rev)
-                if c in filerevmatches:
+                if found:
                     continue
-                filerevmatches[c] = 1
             else:
                 before = l.line[:l.colstart]
                 match = l.line[l.colstart:l.colend]