From 849257dde0365abe43680997edc0ce60100b1a64 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 24 Sep 2021 23:14:38 -0700 Subject: Removed weak optimization for ignorecase skipping --- match.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/match.c b/match.c index 870b4d0..77f5a75 100644 --- a/match.c +++ b/match.c @@ -269,19 +269,9 @@ static match_t *_next_match(match_context_t *ctx, const char *str, pat_t *pat, p // Performance optimization: if the pattern starts with a string literal, // we can just rely on the highly optimized memmem() implementation to skip // past areas where we know we won't find a match. - if (!skip && first->type == BP_STRING && first->min_matchlen > 0) { - if (ctx->ignorecase) { - char c1 = first->args.string[0]; - char *upper = memchr(str, toupper(c1), (size_t)(str - ctx->end)); - char *lower = isalpha(c1) ? memchr(str, tolower(c1), (size_t)(str - ctx->end)) : NULL; - if (upper && lower) - str = upper < lower ? upper : lower; - else if (upper) str = upper; - else if (lower) str = lower; - } else { - char *found = memmem(str, (size_t)(ctx->end - str), first->args.string, first->min_matchlen); - str = found ? found : ctx->end; - } + if (!skip && first->type == BP_STRING && first->min_matchlen > 0 && !ctx->ignorecase) { + char *found = memmem(str, (size_t)(ctx->end - str), first->args.string, first->min_matchlen); + str = found ? found : ctx->end; } if (str > ctx->end) return NULL; -- cgit v1.2.3