From 77a846927e4be2d6a58df8d65c22ff2ab1540275 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 1 Sep 2016 21:49:51 -0700 Subject: [PATCH 2/2] grep: use regex fastmap unless -i This builds on a suggestion by Norihiro Tanaka (Bug#24009). * src/dfasearch.c (GEAcompile): Use a fastmap unless -i. This improves performance 20x for me using the first benchmark given in Bug#24009. --- src/dfasearch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dfasearch.c b/src/dfasearch.c index b5ae623..0838e1f 100644 --- a/src/dfasearch.c +++ b/src/dfasearch.c @@ -151,7 +151,10 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits) struct re_pattern_buffer *pat = &patterns[pcount]; pat->buffer = NULL; pat->allocated = 0; - pat->fastmap = NULL; + + /* Do not use a fastmap with -i, to work around glibc Bug#20381. */ + pat->fastmap = match_icase ? NULL : xmalloc (UCHAR_MAX + 1); + pat->translate = NULL; char const *err = re_compile_pattern (p, len, pat); -- 2.7.4