diff options
author | David Mitchell <davem@iabyn.com> | 2014-02-17 20:20:40 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-03-16 18:03:49 +0000 |
commit | 9fed8d02fb387e26fe15437b6fa29f16095fba55 (patch) | |
tree | fd1e81b4e269b00850ee79e3219d4094a69cbc51 /regexec.c | |
parent | 838b29afa5fb090e885342b04b29a9bd24b07981 (diff) | |
download | perl-9fed8d02fb387e26fe15437b6fa29f16095fba55.tar.gz |
re_intuit_start(): swap another if/else block
Change
{
...
if (has_anchored) {
A;
goto restart;
}
B;
goto hop_and_restart;
}
to
{
...
if (!has_anchored) {
B;
goto hop_and_restart;
}
A;
goto restart;
}
Functionally the same, but will allow simpler code shortly
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 99 |
1 files changed, 52 insertions, 47 deletions
@@ -1278,60 +1278,65 @@ Perl_re_intuit_start(pTHX_ checked_upto = HOPBACKc(endpos, start_shift); DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, " start_shift: %"IVdf" check_at: %"IVdf" endpos: %"IVdf" checked_upto: %"IVdf"\n", (IV)start_shift, (IV)(check_at - strbeg), (IV)(endpos - strbeg), (IV)(checked_upto- strbeg))); + /* Contradict one of substrings */ - if (prog->anchored_substr || prog->anchored_utf8) { - if (prog->substrs->check_ix == 1) { /* check is float */ - /* Have both, check_string is floating */ - assert(rx_origin + start_shift <= check_at); - if (rx_origin + start_shift != check_at) { - /* not at latest position float substr could match: - * Recheck anchored substring, but not floating... */ - if (!check) { - rx_origin = NULL; - goto giveup; - } - DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, - " Looking for anchored substr starting at offset %ld...\n", - (long)(other_last - strpos)) ); - goto do_other_substr; - } + if (!(prog->anchored_substr || prog->anchored_utf8)) { + /* float-only */ + + /* Another way we could have checked stclass at the + current position only: */ + if (ml_anch) { + rx_origin++; + if (!check) + goto giveup; + DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, + " Looking for /%s^%s/m starting at offset %ld...\n", + PL_colors[0], PL_colors[1], + (long)(rx_origin - strpos)) ); + /* XXX DAPM I don't yet know why this is true, but the code + * assumed it when it used to do goto try_at_offset */ + assert(rx_origin != strpos); + goto postprocess_substr_matches; } + if (!(utf8_target ? prog->float_utf8 : prog->float_substr)) /* Could have been deleted */ + goto fail; + /* Check is floating substring. */ + rx_origin = check_at - start_shift; + goto hop_and_restart; + } - hop_and_restart: - rx_origin = HOP3c(rx_origin, 1, strend); - if (rx_origin + start_shift + end_shift > strend) { - /* XXXX Should be taken into account earlier? */ + if (prog->substrs->check_ix == 1) { /* check is float */ + /* Have both, check_string is floating */ + assert(rx_origin + start_shift <= check_at); + if (rx_origin + start_shift != check_at) { + /* not at latest position float substr could match: + * Recheck anchored substring, but not floating... */ + if (!check) { + rx_origin = NULL; + goto giveup; + } DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, - " Could not match STCLASS...\n") ); - goto fail; + " Looking for anchored substr starting at offset %ld...\n", + (long)(other_last - strpos)) ); + goto do_other_substr; } + } + + hop_and_restart: + rx_origin = HOP3c(rx_origin, 1, strend); + if (rx_origin + start_shift + end_shift > strend) { + /* XXXX Should be taken into account earlier? */ DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, - " Looking for %s substr starting at offset %ld...\n", - (prog->substrs->check_ix ? "floating" : "anchored"), - (long)(rx_origin + start_shift - strpos)) ); - goto restart; - } - /* Another way we could have checked stclass at the - current position only: */ - if (ml_anch) { - rx_origin++; - if (!check) - goto giveup; - DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, - " Looking for /%s^%s/m starting at offset %ld...\n", - PL_colors[0], PL_colors[1], - (long)(rx_origin - strpos)) ); - /* XXX DAPM I don't yet know why this is true, but the code - * assumed it when it used to do goto try_at_offset */ - assert(rx_origin != strpos); - goto postprocess_substr_matches; - } - if (!(utf8_target ? prog->float_utf8 : prog->float_substr)) /* Could have been deleted */ - goto fail; - /* Check is floating substring. */ - rx_origin = check_at - start_shift; - goto hop_and_restart; + " Could not match STCLASS...\n") ); + goto fail; + } + DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, + " Looking for %s substr starting at offset %ld...\n", + (prog->substrs->check_ix ? "floating" : "anchored"), + (long)(rx_origin + start_shift - strpos)) ); + goto restart; } + if (rx_origin != s) { DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, " By STCLASS: moving %ld --> %ld\n", |