diff options
Diffstat (limited to 'match.c')
| -rw-r--r-- | match.c | 16 |
1 files changed, 3 insertions, 13 deletions
@@ -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; |
