re_intuit_start(): bias last* vars; revive reghop4
authorDavid Mitchell <davem@iabyn.com>
Sat, 18 Jan 2014 23:46:49 +0000 (23:46 +0000)
committerDavid Mitchell <davem@iabyn.com>
Fri, 7 Feb 2014 22:39:37 +0000 (22:39 +0000)
commit2974eaec4289b97f9c1cee4ae413d4864a578ed0
tree6e5573a2ff3ca41fadc1314dfa0ac2e71df258f0
parente9321f504121b2aad639158a1833b69059ac73eb
re_intuit_start(): bias last* vars; revive reghop4

In the "just matched float substr, now match fixed substr" branch,
initially add an extra prog->anchored_offset to the last and last2 vars;
since a lot of the later calculations involve adding anchored_offset,
doing this early to the last* vars means less work in some cases. In
particular, last is calculated from s by a single

    HOP4(s, prog->anchored_offset-start_shift,...)

rather than two separate

    HOP3(s,   -start_shift,...);
    HOP3(..., prog->anchored_offset,...);

which may mostly cancel each other out.

Similarly with last2. Later, we can skip adding prog->anchored_offset to
last1, since its antecedents already have the bias added.

In the case of failure, calculating a new start position involves an extra
HOP to s, but removes a HOP from other_last, so the two cancel out.

To make this work, I revived the reghop4() function which had been
commented out, and added a HOP4c() wrapper macro. This is like HOP3c(),
but allows you to specify both lower and upper limits. Useful when you
don't know the sign of the offset in advance.

(Yves had earlier added this function, but had commented it out until such
time as it was actually used.)

I also added some extra comments to this block and removed the comment
about it being maybe broken under utf8, since I'm auditing the code for
utf8-safeness.
embed.fnc
embed.h
proto.h
regexec.c