summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-12-26 18:13:36 -0700
committerKarl Williamson <khw@cpan.org>2017-12-30 10:41:59 -0700
commitf844b04230c9dbb5970369720a687afeea605cb3 (patch)
treecd08e7751c272eaa3aaf9812286bc55cec2a3a2e /regexec.c
parentdce3f5c3fd788f1c2e451e3760f05a347c949eff (diff)
downloadperl-f844b04230c9dbb5970369720a687afeea605cb3.tar.gz
regexec.c: Replace loop by memchr()
This loop can be potentially very long as it is used to find the next place there is a potential match in something like /(foo)+abc/. (It's trying to find the 'a' in that example.
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/regexec.c b/regexec.c
index 98421e1aac..5c9d7b69ee 100644
--- a/regexec.c
+++ b/regexec.c
@@ -8653,9 +8653,12 @@ NULL
}
else { /* Not utf8_target */
if (ST.c1 == ST.c2) {
- while (locinput <= ST.maxpos &&
- UCHARAT(locinput) != ST.c1)
- locinput++;
+ locinput = (char *) memchr(locinput,
+ ST.c1,
+ ST.maxpos + 1 - locinput);
+ if (! locinput) {
+ locinput = ST.maxpos + 1;
+ }
}
else {
U8 c1_c2_bits_differing = ST.c1 ^ ST.c2;