summaryrefslogtreecommitdiff
path: root/patch-ids.c
diff options
context:
space:
mode:
authorLibravatar René Scharfe <rene.scharfe@lsrfire.ath.cx>2009-07-02 00:05:17 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-07-01 19:16:48 -0700
commit49de3216983cc921ea66ade18a8521d4d74bbf3f (patch)
treeccc9ea4188f483f05529e72b8afd43a372b4d545 /patch-ids.c
parentgrep: print context hunk marks between files (diff)
downloadtgif-49de3216983cc921ea66ade18a8521d4d74bbf3f.tar.xz
grep: handle pre context lines on demand
Factor out pre context line handling into the new function show_pre_context() and change the algorithm to rewind by looking for newline characters and roll forward again, instead of maintaining an array of line beginnings and ends. This is slower for hits, but the cost for non-matching lines becomes zero. Normally, there are far more non-matching lines, so the time spent in total decreases. Before this patch (current Linux kernel repo, best of five runs): $ time git grep --no-ext-grep -B1 memset >/dev/null real 0m2.134s user 0m1.932s sys 0m0.196s $ time git grep --no-ext-grep -B1000 memset >/dev/null real 0m12.059s user 0m11.837s sys 0m0.224s The same with this patch: $ time git grep --no-ext-grep -B1 memset >/dev/null real 0m2.117s user 0m1.892s sys 0m0.228s $ time git grep --no-ext-grep -B1000 memset >/dev/null real 0m2.986s user 0m2.696s sys 0m0.288s Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'patch-ids.c')
0 files changed, 0 insertions, 0 deletions