diff options
author | Karl Williamson <khw@cpan.org> | 2018-11-06 18:02:07 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-11-16 10:48:18 -0700 |
commit | 523a2924740c68b1653d1c68aea5c8d7fb9161e4 (patch) | |
tree | 87ade84a78e2664e942b899dafb4bfed3faed1e6 | |
parent | 2ac479f0aebdb9a80e57fb49182be8ddfed7a35f (diff) | |
download | perl-523a2924740c68b1653d1c68aea5c8d7fb9161e4.tar.gz |
regcomp.c: Don't restart parse now if doing so later
Prior to this commit, if it became apparent that long branches were
going to be needed, 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.
This can avoid an almost complete reparse in some situations.
-rw-r--r-- | regcomp.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -358,8 +358,12 @@ struct RExC_state_t { #define REQUIRE_BRANCHJ(flagp, restart_retval) \ STMT_START { \ RExC_use_BRANCHJ = 1; \ - *flagp |= RESTART_PARSE; \ - return restart_retval; \ + 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 #define REQUIRE_PARENS_PASS \ |