From f43fe791dd4aa8f2ca079ed461349f24de32276a Mon Sep 17 00:00:00 2001 From: Norihiro Tanaka Date: Tue, 13 Oct 2015 09:19:10 +0900 Subject: [PATCH 2/2] grep: use grep matcher for grep -Fw in single byte locales In in single byte locales, KWset and DFA are used for words matching by grep. It is faster than kwset matcher, as kwset matcher calls kwsexec many times until matches words. So we use grep matcher for grep -Fw in single byte locales. * src/grep.c (main): Change pattern for fgrep into grep for grep -Fw in single byte locales. --- src/grep.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/grep.c b/src/grep.c index d8ea70f..0ca0d9a 100644 --- a/src/grep.c +++ b/src/grep.c @@ -2563,9 +2563,12 @@ main (int argc, char **argv) /* If fgrep in a multibyte locale, then use grep if either (1) case is ignored (where grep is typically faster), or - (2) the pattern has an encoding error (where fgrep might not work). */ - if (compile == Fcompile && MB_CUR_MAX > 1 - && (match_icase || contains_encoding_error (keys, keycc))) + (2) the pattern matches words (where grep is typically faster), or + (3) the pattern has an encoding error (where fgrep might not work). */ + if (compile == Fcompile + && (MB_CUR_MAX > 1 && (match_icase + || contains_encoding_error (keys, keycc))) + || (MB_CUR_MAX == 1 && match_words)) { size_t new_keycc; char *new_keys; -- 2.4.6