regexec.c: reorder statements for speed
authorKarl Williamson <public@khwilliamson.com>
Sun, 31 Oct 2010 17:50:08 +0000 (11:50 -0600)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 31 Oct 2010 22:59:54 +0000 (15:59 -0700)
The call to reginclass is guaranteed by constness to not change
locinput, so if going to fail don't waste time calling it.

regexec.c

index 9acadbb..ca6c9e4 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -3632,11 +3632,11 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
        case ANYOF:
            if (utf8_target) {
                STRLEN inclasslen = PL_regeol - locinput;
+               if (locinput >= PL_regeol)
+                   sayNO;
 
                if (!reginclass(rex, scan, (U8*)locinput, &inclasslen, utf8_target))
                    goto anyof_fail;
-               if (locinput >= PL_regeol)
-                   sayNO;
                locinput += inclasslen;
                nextchr = UCHARAT(locinput);
                break;
@@ -3644,10 +3644,10 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
            else {
                if (nextchr < 0)
                    nextchr = UCHARAT(locinput);
-               if (!REGINCLASS(rex, scan, (U8*)locinput))
-                   goto anyof_fail;
                if (!nextchr && locinput >= PL_regeol)
                    sayNO;
+               if (!REGINCLASS(rex, scan, (U8*)locinput))
+                   goto anyof_fail;
                nextchr = UCHARAT(++locinput);
                break;
            }