comparison mercurial/commands.py @ 20836:a8b4541bb961

grep: reuse the first "util.binary()" result for efficiency Before this patch, to check whether the file in the specified revision is binary or not, "util.binary()" is invoked via internal function "binary()" of "hg grep" once per a line of "hg grep" output, even though binary-ness is not changed in the same file. This patch reuses the first "util.binary()" invocation result by annotating internal function "binary()" with "@util.cachefunc". Performance improvement measured by "hgperf grep -r 88d8e568add1 vfs mercurial/scmutil.py": before this patch: ! wall 0.024000 comb 0.015600 user 0.015600 sys 0.000000 (best of 118) after this patch: ! wall 0.023000 comb 0.015600 user 0.015600 sys 0.000000 (best of 123) Status of recent(88d8e568add1) "mercurial/scmutil.py": # of lines: 919 (may affect cost of search) # of bytes: 29633 (may affect cost of "util.binary()") # of matches: 22 (may affect frequency of "util.binary()")
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 15 Feb 2014 19:52:36 +0900
parents 8c210b169c69
children 191a0ae37767
comparison
equal deleted inserted replaced
20835:0e8417131a29 20836:a8b4541bb961
3342 def display(fn, ctx, pstates, states): 3342 def display(fn, ctx, pstates, states):
3343 rev = ctx.rev() 3343 rev = ctx.rev()
3344 datefunc = ui.quiet and util.shortdate or util.datestr 3344 datefunc = ui.quiet and util.shortdate or util.datestr
3345 found = False 3345 found = False
3346 filerevmatches = {} 3346 filerevmatches = {}
3347 @util.cachefunc
3347 def binary(): 3348 def binary():
3348 flog = getfile(fn) 3349 flog = getfile(fn)
3349 return util.binary(flog.read(ctx.filenode(fn))) 3350 return util.binary(flog.read(ctx.filenode(fn)))
3350 3351
3351 if opts.get('all'): 3352 if opts.get('all'):