summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-11-06 18:10:36 -0700
committerKarl Williamson <khw@cpan.org>2018-11-16 10:48:19 -0700
commitd1be211cd36639caeb3c7482759d9bed530ecaad (patch)
tree441cebda3258e8c8abd7d07670c4f4defa0075ce /regcomp.c
parent523a2924740c68b1653d1c68aea5c8d7fb9161e4 (diff)
downloadperl-d1be211cd36639caeb3c7482759d9bed530ecaad.tar.gz
regcomp.c: Don't restart parse for /d to /u if reparsing anyway
Prior to this commit, if the rules changed from /d to /u, the parse was immediately restarted. This commit changes that so that it doesn't do this if it is known that the parse will be redone anyway, but a full parse needs to done first in order to count the parentheses. Doing this can avoid the need for an almost full extra reparse.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 6c33b219c5..1c3664b743 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -349,8 +349,12 @@ struct RExC_state_t {
if (DEPENDS_SEMANTICS) { \
set_regex_charset(&RExC_flags, REGEX_UNICODE_CHARSET); \
RExC_uni_semantics = 1; \
+ if (LIKELY(RExC_total_parens >= 0)) { \
+ /* No need to restart the parse immediately if we're \
+ * going to reparse anyway to count parens */ \
*flagp |= RESTART_PARSE; \
return restart_retval; \
+ } \
} \
} STMT_END