re_intuit_start(): eliminate one label
authorDavid Mitchell <davem@iabyn.com>
Mon, 17 Feb 2014 19:07:08 +0000 (19:07 +0000)
committerDavid Mitchell <davem@iabyn.com>
Sun, 16 Mar 2014 18:03:49 +0000 (18:03 +0000)
Currently the code looks like:

    if (rx_origin + start_shift >= check_at)
        goto retry_floating_check;

    ....

  retry_floating_check:
    rx_origin = check_at - start_shift;
    goto hop_and_restart;

But that conditional only kicks in when the floating substring (which was
the check substring) matched, so this condition always applies:

    rx_origin + start_shift <= check_at

So the condition in the code will only ever be true when

    rx_origin + start_shift == check_at

In this case, this assignment is a noop:

    rx_origin = check_at - start_shift;

So skip it and jump directly to hop_and_restart. This eliminates the
retry_floating_check: label.

regexec.c

index 5d70686..73bd532 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -1296,8 +1296,10 @@ Perl_re_intuit_start(pTHX_
                    goto restart;
                }
                /* Have both, check_string is floating */
-               if (rx_origin + start_shift >= check_at) /* Contradicts floating=check */
-                   goto retry_floating_check;
+               assert(rx_origin + start_shift <= check_at);
+               if (rx_origin + start_shift == check_at)
+                    /* already at latest position float substr could match */
+                   goto hop_and_restart;
                /* Recheck anchored substring, but not floating... */
                if (!check) {
                     rx_origin = NULL;
@@ -1327,7 +1329,6 @@ Perl_re_intuit_start(pTHX_
            if (!(utf8_target ? prog->float_utf8 : prog->float_substr)) /* Could have been deleted */
                goto fail;
            /* Check is floating substring. */
-         retry_floating_check:
            rx_origin = check_at - start_shift;
            goto hop_and_restart;
        }