diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-01 22:56:39 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-01 22:56:39 -0700 |
commit | af6af288eac28951b5eee1eaaf373e22b2193b7b (patch) | |
tree | 41dcd89cb183bbf314984f41b676755cc59047a2 /tests/status | |
parent | d1060aa9f7d1daca37656a35751241ddce67ae75 (diff) | |
download | grep-af6af288eac28951b5eee1eaaf373e22b2193b7b.tar.gz |
grep: /dev/null output speedup
This sped up 'seq 10000000000 | grep . >/dev/null' by a factor of
380,000 on my platform (Fedora 23, x86-64, AMD Phenom II X4 910e,
en_US.UTF-8 locale).
* NEWS: Document this.
* src/grep.c (grepbuf): exit_on_match no longer implies that -q
was specified, so when a match is found, exit with exit_failure if
an error was also found.
(grepdesc): Omit unnecessary S_ISREG and st_ino checks.
out_stat.st_ino is zero if stdout is not a regular file,
and this cannot possibly equal st->st_ino.
(main): Omit duplicate initialization of exit_failure. Do not
bother with isatty unless -q is not used and stdout is a character
special file and --color=auto and TERM says colorization is
possible. Most importantly, set exit_on_match if the output is
/dev/null.
* tests/grep-dev-null-out: New test.
* tests/Makefile.am (TESTS): Add it.
* tests/status: Do not require grep to actually read all the input
files when the output is /dev/null and a matching line has been
found.
Diffstat (limited to 'tests/status')
-rwxr-xr-x | tests/status | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/status b/tests/status index 9de98dff..2a2d6e04 100755 --- a/tests/status +++ b/tests/status @@ -47,9 +47,9 @@ else fail=1 fi - # should return 2 file not found + # should return 0 (found a match) or 2 (file not found) echo "abcd" | grep -E -s 'abc' - MMMMMMMM.MMM > /dev/null 2>&1 - if test $? -ne 2 ; then + if test $? -ne 0 && test $? -ne 2 ; then echo "Status: Wrong status code, test \#5 failed" fail=1 fi |