File ignore-case-multibyte-non-utf8.patch of Package grep.35702
From c7c8bcdefe7be5f59a242eea63df7f64eacb6a09 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Wed, 19 Feb 2014 19:31:43 -0800
Subject: [PATCH] grep -i: avoid a performance regression in multibyte non-UTF8
locales
* src/main.c: Include dfa.h.
(trivial_case_ignore): Perform this optimization only for UTF8 locales.
This rectifies a 100-200x performance regression in non-UTF8 multi-byte
locales like ja_JP.eucJP. The regression was introduced by the 10x
UTF8/grep-i speedup, commit v2.16-4-g97318f5.
Reported by Norihiro Tanaka in http://debbugs.gnu.org/16232#50
diff --git a/src/main.c b/src/main.c
index bd20297..56ec6b3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,6 +34,7 @@
#include "c-ctype.h"
#include "closeout.h"
#include "colorize.h"
+#include "dfa.h"
#include "error.h"
#include "exclude.h"
#include "exitfail.h"
@@ -1883,6 +1884,11 @@ static bool
trivial_case_ignore (size_t len, char const *keys,
size_t *new_len, char **new_keys)
{
+ /* Perform this translation only for UTF-8. Otherwise, this would induce
+ a 100-200x performance penalty for non-UTF8 multibyte locales. */
+ if ( ! using_utf8 ())
+ return false;
+
/* FIXME: consider removing the following restriction:
Reject if KEYS contain ASCII '\\' or '['. */
if (memchr (keys, '\\', len) || memchr (keys, '[', len))
--
2.26.2