Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce if for decreasing counter on OP_REPEAT_INC #9393

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2531,6 +2531,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
#define MATCH_CACHE_DEBUG_HIT ((void) 0)
#endif

#define MATCH_CACHE_HIT ((void) 0)

# define CHECK_MATCH_CACHE do {\
if (msa->match_cache_status == MATCH_CACHE_STATUS_ENABLED) {\
const OnigCacheOpcode *cache_opcode;\
Expand All @@ -2541,8 +2543,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
uint8_t match_cache_point_mask = 1 << (match_cache_point & 7);\
MATCH_CACHE_DEBUG;\
if (msa->match_cache_buf[match_cache_point_index] & match_cache_point_mask) {\
MATCH_CACHE_DEBUG_HIT;\
if (*pbegin == OP_REPEAT_INC) stkp->u.repeat.count--;\
MATCH_CACHE_DEBUG_HIT; MATCH_CACHE_HIT;\
if (cache_opcode->lookaround_nesting == 0) goto fail;\
else if (cache_opcode->lookaround_nesting < 0) {\
if (check_extended_match_cache_point(msa->match_cache_buf, match_cache_point_index, match_cache_point_mask)) {\
Expand Down Expand Up @@ -3814,9 +3815,15 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
/* end of repeat. Nothing to do. */
}
else if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) {
#ifdef USE_MATCH_CACHE
if (*pbegin == OP_REPEAT_INC) {
#undef MATCH_CACHE_HIT
#define MATCH_CACHE_HIT stkp->u.repeat.count--;
CHECK_MATCH_CACHE;
#undef MATCH_CACHE_HIT
#define MATCH_CACHE_HIT ((void) 0)
}
#endif
STACK_PUSH_ALT(p, s, sprev, pkeep);
p = STACK_AT(si)->u.repeat.pcode; /* Don't use stkp after PUSH. */
}
Expand Down