aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-07-19 13:33:51 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-07-19 13:33:51 -0700
commit62e7d654bd70db89cb38e5d9efeb9a9b0e9cf202 (patch)
treedf30269408b01adff18904cd4aa04d57866caaae
parent01410bd09d3fdbeb40f72999e46aefa99e205e73 (diff)
Disable optimization when `skip` is non-null
-rw-r--r--match.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/match.c b/match.c
index 240e2fa..c62a068 100644
--- a/match.c
+++ b/match.c
@@ -108,7 +108,7 @@ match_t *next_match(def_t *defs, file_t *f, match_t *prev, pat_t *pat, pat_t *sk
// Performance optimization: if the pattern starts with a string literal,
// we can just rely on the highly optimized strstr()/strcasestr()
// implementations to skip past areas where we know we won't find a match.
- if (first->type == BP_STRING) {
+ if (!skip && first->type == BP_STRING) {
for (size_t i = 0; i < first->min_matchlen; i++)
if (first->args.string[i] == '\0')
goto pattern_search;