summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2012-03-20 00:52:46 +0100
committerYves Orton <demerphq@gmail.com>2012-03-20 11:20:06 +0100
commit729aaeb502af62aff1b72f90b3d33e7218b94e0c (patch)
treee9a8eddfa1d0ad2f569c5a8089de477d6ead7c7a
parenta40630bf5c45bc9d528e1eacffde2666ad23c6b2 (diff)
downloadperl-729aaeb502af62aff1b72f90b3d33e7218b94e0c.tar.gz
correct logic error that meant that "last" might not be updated properly
While checking into an unrelated issue I realized "last" might not be reset under certain circumstances. Although I could not find a way to make anything bad happen from perl, I decided to fix it, at worst we waste a few CPU cycles setting "last" to NULL more often than we should.
-rw-r--r--regcomp.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/regcomp.c b/regcomp.c
index 70d6c3b38a..b106cc166e 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -3366,13 +3366,16 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
/* handle unmergable node -
* noper may either be a triable node which can not be tried
* together with the current trie, or a non triable node */
- if ( last && trietype != NOTHING ) {
- /* if last is set then we have found at least two triable branch
- * sequences in a row of a similar trietype so we can turn them
- * into a trie */
- make_trie( pRExC_state,
- startbranch, first, cur, tail, count,
- trietype, depth+1 );
+ if ( last ) {
+ /* If last is set and trietype is not NOTHING then we have found
+ * at least two triable branch sequences in a row of a similar
+ * trietype so we can turn them into a trie. If/when we
+ * allow NOTHING to start a trie sequence this condition will be
+ * required, and it isn't expensive so we leave it in for now. */
+ if ( trietype != NOTHING )
+ make_trie( pRExC_state,
+ startbranch, first, cur, tail, count,
+ trietype, depth+1 );
last = NULL; /* note: we clear/update first, trietype etc below, so we dont do it here */
}
if ( noper_trietype