This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
S_regmatch(): combine CURLY_B_min/_known states
authorDavid Mitchell <davem@iabyn.com>
Wed, 15 Aug 2018 17:02:53 +0000 (18:02 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 26 Aug 2018 19:57:34 +0000 (20:57 +0100)
commit21cbe0098921b51ccea087caa9ad5c71b2cda029
tree9c02a0f2f2bc312bfafd7651d15e484ac0211d23
parent42f10b3ffcb09f2c3fb2fb2600565b3fe588f922
S_regmatch(): combine CURLY_B_min/_known states

There are currently two similar backtracking states for simple
non-greedy pattern repeats:

    CURLY_B_min
    CURLY_B_min_known

the latter is a variant of the former for when the character which must
follow the repeat is known, e.g.  /(...)*?X.../, which allows quick
skipping to the next viable position.

The code for the two cases:

    case CURLY_B_min_fail:
    case CURLY_B_min_known_fail:

share a lot of similarities. This commit merges the two states into a
single CURLY_B_min state, with an associated single CURLY_B_min_fail
fail state.

That one code block can handle both types, with a single

    if (ST.c1 == CHRTEST_VOID) ...

test to choose between the two variant parts of the code.

This makes the code smaller and more maintainable, at the cost of one
extra test per backtrack.
regcomp.sym
regexec.c
regnodes.h