Avoid duplicate table look ups.
authorKarl Williamson <public@khwilliamson.com>
Tue, 28 Aug 2012 21:29:42 +0000 (15:29 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 28 Aug 2012 22:24:47 +0000 (16:24 -0600)
These two spots both are matching 'c+' where 'c' is some character
against a Unicode table.  Prior to this patch, if it matched a single
'c', it would fall into a while loop, where it matches that same 'c'
again.  Simply increment the pointer past the first match, and the while loop
will start looking for succeeding matches starting with the next
character in the input.

regexec.c

index c5fd04d..040e16a 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -4017,6 +4017,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
                            if (swash_fetch(PL_utf8_X_RI,
                                            (U8*)locinput, utf8_target))
                            {
+                                locinput += UTF8SKIP(locinput);
                                while (locinput < PL_regeol
                                        && swash_fetch(PL_utf8_X_RI,
                                                        (U8*)locinput, utf8_target))
@@ -4027,6 +4028,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
                                    if (swash_fetch(PL_utf8_X_T,
                                            (U8*)locinput, utf8_target))
                            {
+                                locinput += UTF8SKIP(locinput);
                                while (locinput < PL_regeol
                                        && swash_fetch(PL_utf8_X_T,
                                                        (U8*)locinput, utf8_target))
@@ -4087,7 +4089,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
                                    }
                                }
                            }
-                       }
+                        }
 
                        /* Match any extender */
                        while (locinput < PL_regeol