summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-09-25 17:14:56 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-09-26 01:06:25 -0700
commit225362ac3967a6ca6343958d7ad395a3dee1b63c (patch)
tree83e5b8ce40c8b124ac9009541a143aeb39f8c6ec
parentaaefbfa486df2587e25c8b59d1cca5f2092e7c7a (diff)
downloadgrep-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.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/grep.c b/src/grep.c
index 1e5d0fa4..046f17f1 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -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 (;;)