When computing minimum length, don't scan subsequent branches if any branch in
a group has zero minimum length.
This commit is contained in:
parent
7bbdc58513
commit
27d40c8ad8
|
@ -139,6 +139,10 @@ case after a bumpalong and (b) when one case has been found, it searches only
|
||||||
up to that position for an earlier occurrence of the other case. This fix
|
up to that position for an earlier occurrence of the other case. This fix
|
||||||
applies to both interpretive pcre2_match() and to pcre2_dfa_match().
|
applies to both interpretive pcre2_match() and to pcre2_dfa_match().
|
||||||
|
|
||||||
|
30. While scanning to find the minimum length of a group, if any branch has
|
||||||
|
minimum length zero, there is no need to scan any subsequent branches (a small
|
||||||
|
compile-time performance improvement).
|
||||||
|
|
||||||
|
|
||||||
Version 10.33 16-April-2019
|
Version 10.33 16-April-2019
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
|
@ -223,7 +223,9 @@ for (;;)
|
||||||
|
|
||||||
/* Reached end of a branch; if it's a ket it is the end of a nested
|
/* Reached end of a branch; if it's a ket it is the end of a nested
|
||||||
call. If it's ALT it is an alternation in a nested call. If it is END it's
|
call. If it's ALT it is an alternation in a nested call. If it is END it's
|
||||||
the end of the outer call. All can be handled by the same code. */
|
the end of the outer call. All can be handled by the same code. If the
|
||||||
|
length of any branch is zero, there is no need to scan any subsequent
|
||||||
|
branches. */
|
||||||
|
|
||||||
case OP_ALT:
|
case OP_ALT:
|
||||||
case OP_KET:
|
case OP_KET:
|
||||||
|
@ -233,7 +235,7 @@ for (;;)
|
||||||
case OP_END:
|
case OP_END:
|
||||||
if (length < 0 || (!had_recurse && branchlength < length))
|
if (length < 0 || (!had_recurse && branchlength < length))
|
||||||
length = branchlength;
|
length = branchlength;
|
||||||
if (op != OP_ALT) return length;
|
if (op != OP_ALT || length == 0) return length;
|
||||||
nextbranch = cc + GET(cc, 1);
|
nextbranch = cc + GET(cc, 1);
|
||||||
cc += 1 + LINK_SIZE;
|
cc += 1 + LINK_SIZE;
|
||||||
branchlength = 0;
|
branchlength = 0;
|
||||||
|
|
Loading…
Reference in New Issue