This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
move intuit call from pp_match() into regexec()
authorDavid Mitchell <davem@iabyn.com>
Tue, 18 Jun 2013 13:44:12 +0000 (14:44 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 28 Jul 2013 09:33:35 +0000 (10:33 +0100)
commit7fadf4a7d2f1ec5af858f49a8493aacdee541a8b
tree371845744ff5c6ebfa93303c23054a69ed1adb91
parent2c75e3628bc433543b3e475c87a64fb9e8d79871
move intuit call from pp_match() into regexec()

Currently the main part of pp_match() looks like:

    if (can_use_intuit) {
        if (!intuit_start())
            goto nope;
        if (can_match_based_only_on_intuit_result) {
            ... set up $&, $-[0] etc ...
            goto gotcha;
        }
    }
    if (!regexec(..., REXEC_CHECKED|r_flags))
        goto nope;

  gotcha:
    ...

This rather breaks the regex API encapulation. The caller of the regex
engine shouldn't have to worry about whether to call intuit() or
regexec(), and to know to set $& in the intuit-only case.

So, move all the intuit-calling and $& setting into regexec itself.
This is cleaner, and will also shortly allow us to enable intuit-only
matches in pp_subst() too. After this change, the code above looks like
(in its entirety):

    if (!regexec(..., r_flags))
        goto nope;

    ...

There, isn't that nicer?
pp_hot.c
regexec.c