turns out we cant maike a jump trie that starts with a NOTHING regop
authorYves Orton <demerphq@gmail.com>
Thu, 21 Jun 2012 18:42:07 +0000 (20:42 +0200)
committerYves Orton <demerphq@gmail.com>
Sat, 23 Jun 2012 09:09:21 +0000 (11:09 +0200)
NOTHING nodes are 1 regop wide. We need 2 regops worth of
space. Which means that we can not safely optimise a sequence
that starts with a NOTHING regop that needs to turn into
a jump trie. We therefore ignore such sequences.

see perl #113770 for details.

regcomp.c
t/re/re_tests

index acecaa9..d124034 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -3379,7 +3379,6 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                                  * the end pointer. */
                                 if ( !first ) {
                                     first = cur;
-                                    trietype = noper_trietype;
                                    if ( noper_trietype == NOTHING ) {
 #if !defined(DEBUGGING) && !defined(NOJUMPTRIE)
                                        regnode * const noper_next = regnext( noper );
@@ -3387,8 +3386,15 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                                        U8 noper_next_trietype = noper_next_type ? TRIE_TYPE( noper_next_type ) :0;
 #endif
 
-                                        if ( noper_next_trietype )
+                                        if ( noper_next_trietype ) {
                                            trietype = noper_next_trietype;
+                                        } else if (noper_next_type)  {
+                                            /* a NOTHING regop is 1 regop wide. We need at least two
+                                             * for a trie so we can't merge this in */
+                                            first = NULL;
+                                        }
+                                    } else {
+                                        trietype = noper_trietype;
                                     }
                                 } else {
                                     if ( trietype == NOTHING )
index 22d3eda..327f585 100644 (file)
@@ -1678,4 +1678,6 @@ ab[c\\\](??{"x"})]{3}d    ab\\](d y       -       -
 ^(?:(X)?(\d)|(X)?(\d\d))$      X12     y       $1-$2-$3-$4     --X-12
 ^(?:(XX)?(\d)|(XX)?(\d\d))$    XX12    y       $1-$2-$3-$4     --XX-12
 
+# rt 113770
+\A(?>\[(?:(?:)(?:R){1}|T|V?|A)\])\z    [A]     y       $&      [A]
 # vim: softtabstop=0 noexpandtab