diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-10 22:39:36 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-12 00:47:50 -0800 |
commit | a26345b6085340ebd61e156aa8154a80196bee0f (patch) | |
tree | d8aa79fd39d8d3418383d52dbad8f4b7401a8e93 /help.h | |
parent | cb572206d9dac4ba52878e7e1a4a7028d85707ab (diff) | |
download | git-a26345b6085340ebd61e156aa8154a80196bee0f.tar.gz git-a26345b6085340ebd61e156aa8154a80196bee0f.tar.xz |
grep: optimize built-in grep by skipping lines that do not hit
The internal "grep" engine we use checks for hits line-by-line, instead of
letting the underlying regexec()/fixmatch() routines scan for the first
match from the rest of the buffer. This was a major source of overhead
compared to the external grep.
Introduce a "look-ahead" mechanism to find the next line that would
potentially match by using regexec()/fixmatch() in the remainder of the
text to skip unmatching lines, and use it when the query criteria is
simple enough (i.e. punt for an advanced grep boolean expression like
"lines that have both X and Y but not Z" for now) and we are not running
under "-v" (aka "--invert-match") option.
Note that "-L" (aka "--files-without-match") is not a reason to disable
this optimization. Under the option, we are interested if the file has
any hit at all, and that is what we determine reliably with or without the
optimization.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'help.h')
0 files changed, 0 insertions, 0 deletions