diff options
author | David Mitchell <davem@iabyn.com> | 2014-01-18 23:46:49 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-02-07 22:39:37 +0000 |
commit | 2974eaec4289b97f9c1cee4ae413d4864a578ed0 (patch) | |
tree | 6e5573a2ff3ca41fadc1314dfa0ac2e71df258f0 /embed.h | |
parent | e9321f504121b2aad639158a1833b69059ac73eb (diff) | |
download | perl-2974eaec4289b97f9c1cee4ae413d4864a578ed0.tar.gz |
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.
Diffstat (limited to 'embed.h')
-rw-r--r-- | embed.h | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -1004,6 +1004,7 @@ #define regcppop(a,b) S_regcppop(aTHX_ a,b) #define regcppush(a,b,c) S_regcppush(aTHX_ a,b,c) #define reghop3 S_reghop3 +#define reghop4 S_reghop4 #define reghopmaybe3 S_reghopmaybe3 #define reginclass(a,b,c,d,e) S_reginclass(aTHX_ a,b,c,d,e) #define regmatch(a,b,c) S_regmatch(aTHX_ a,b,c) @@ -1011,9 +1012,6 @@ #define regtry(a,b) S_regtry(aTHX_ a,b) #define to_byte_substr(a) S_to_byte_substr(aTHX_ a) #define to_utf8_substr(a) S_to_utf8_substr(aTHX_ a) -# if defined(XXX_dmq) -#define reghop4 S_reghop4 -# endif # endif # if defined(PERL_IN_UTF8_C) || defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) #define _to_fold_latin1(a,b,c,d) Perl__to_fold_latin1(aTHX_ a,b,c,d) |