re_intuit_start(): do 'not at start' check on BOL
authorDavid Mitchell <davem@iabyn.com>
Tue, 18 Mar 2014 21:32:39 +0000 (21:32 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 19 Mar 2014 18:25:54 +0000 (18:25 +0000)
commit7bb3b9eb56c4b9374abfae3780eeb77c607bb1a5
tree04453e295ba2ea12ba5457757d49534a9a870240
parentd0d4464849e2b30aee89c175ccb5465795de10ce
re_intuit_start(): do 'not at start' check on BOL

The quick reject test that says "if a pattern has an absolute anchor,
then immediately reject if strpos != strbeg", currently skips that test
if PREGf_ANCH_GPOS is present. Instead, skip unless BOL or SBOL is present.

This means that something like /^abc\G/ will still do the quick reject
test.

I can't think of any example that will actually give a measurable
performance boost, and this is a fairly unlikely scenario, but the code is
more logical this way, and makes it more robust against future changes
(it's less likely to suddenly skip the quick test where it used to do it).

I've also updated the commentary on why we don't do a quick /\G/ test
akin to the /^/ test, and added some more info about why we test for the
PREGf_IMPLICIT flag.

And I've added an assert about PREGf_IMPLICIT too.
regexec.c