diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2009-07-02 00:05:17 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-07-01 19:16:48 -0700 |
commit | 49de3216983cc921ea66ade18a8521d4d74bbf3f (patch) | |
tree | ccc9ea4188f483f05529e72b8afd43a372b4d545 /test-sigchain.c | |
parent | 046802d015b3be2e055ae68f29f76741023bc32d (diff) | |
download | git-49de3216983cc921ea66ade18a8521d4d74bbf3f.tar.gz git-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 'test-sigchain.c')
0 files changed, 0 insertions, 0 deletions