This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tighten uses of regex synthetic start class
authorKarl Williamson <khw@cpan.org>
Mon, 22 Sep 2014 19:59:39 +0000 (13:59 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 29 Sep 2014 19:07:07 +0000 (13:07 -0600)
commitb35552de5cea8eb47ccb046284ecb9a099430255
tree9cddbc9de1b38404bcf6fdae9e65f46b5a5d3e79
parentdea37815c59831b7e586fa51968348fbb8009e1a
Tighten uses of regex synthetic start class

A synthetic start class (SSC) is generated by the regular expression
pattern compiler to give a consolidation of all the possible things that
can match at the beginning of where a pattern can possibly match.
For example
    qr/a?bfoo/;
requires the match to begin with either an 'a' or a 'b'.  There are no
other possibilities.  We can set things up to quickly scan for either of
these in the target string, and only when one of these is found do we
need to look for 'foo'.

There is an overhead associated with using SSCs.  If the number of
possibilities that the SSC excludes is relatively small, it can be
counter-productive to use them.

This patch creates a crude sieve to decide whether to use an SSC or not.
If the SSC doesn't exclude at least half the "likely" possiblities, it
is discarded.  This patch is a starting point, and can be refined if
necessary as we gain experience.

See thread beginning with
http://nntp.perl.org/group/perl.perl5.porters/212644

In many patterns, no SSC is generated; and with the advent of tries,
SSC's have become less important, so whatever we do is not terribly
critical.
embed.fnc
embed.h
ext/re/t/regop.t
proto.h
regcomp.c
regen/unicode_constants.pl
t/re/pat.t
unicode_constants.h