diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2014-09-25 17:14:56 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2014-09-26 01:06:25 -0700 |
commit | 225362ac3967a6ca6343958d7ad395a3dee1b63c (patch) | |
tree | 83e5b8ce40c8b124ac9009541a143aeb39f8c6ec | |
parent | aaefbfa486df2587e25c8b59d1cca5f2092e7c7a (diff) | |
download | grep-225362ac3967a6ca6343958d7ad395a3dee1b63c.tar.gz |
grep: don't check extensively for invalid prefix bytes unless -P
Problem reported by Jim Meyering in: http://bugs.gnu.org/18454#56
* src/grep.c (grep): After the first buffer is checked, leave the
file-type checker in TEXTBIN_UNKNOWN state only when -P is used.
Only the -P matcher has performance problems with checking binary
data that make it worthwhile to check every prefix input byte so
the -P matcher's TEXTBIN_UNKNOWN optimizations can come into play.
Other matchers can simply check the data directly, and using
TEXTBIN_UNKNOWN with them slows 'grep' down for no benefit.
-rw-r--r-- | src/grep.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1298,6 +1298,8 @@ grep (int fd, struct stat const *st) nul_zapper = eol; skip_nuls = skip_empty_lines; } + else if (execute != Pexecute) + textbin = TEXTBIN_TEXT; } for (;;) |