summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regexec.c15
-rw-r--r--t/perf/benchmarks17
2 files changed, 29 insertions, 3 deletions
diff --git a/regexec.c b/regexec.c
index 013ccc54a8..f6f293d56e 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1881,8 +1881,11 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
REXEC_FBC_UTF8_CLASS_SCAN(
reginclass(prog, c, (U8*)s, (U8*) strend, utf8_target));
}
+ else if (ANYOF_FLAGS(c)) {
+ REXEC_FBC_CLASS_SCAN(reginclass(prog,c, (U8*)s, (U8*)s+1, 0));
+ }
else {
- REXEC_FBC_CLASS_SCAN(REGINCLASS(prog, c, (U8*)s, 0));
+ REXEC_FBC_CLASS_SCAN(ANYOF_BITMAP_TEST(c, *((U8*)s)));
}
break;
@@ -8892,8 +8895,14 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
scan += UTF8SKIP(scan);
hardcount++;
}
- } else {
- while (scan < loceol && REGINCLASS(prog, p, (U8*)scan, 0))
+ }
+ else if (ANYOF_FLAGS(p)) {
+ while (scan < loceol
+ && reginclass(prog, p, (U8*)scan, (U8*)scan+1, 0))
+ scan++;
+ }
+ else {
+ while (scan < loceol && ANYOF_BITMAP_TEST(p, *((U8*)scan)))
scan++;
}
break;
diff --git a/t/perf/benchmarks b/t/perf/benchmarks
index 4a57175e1d..ac698500e3 100644
--- a/t/perf/benchmarks
+++ b/t/perf/benchmarks
@@ -1348,4 +1348,21 @@
setup => 'my $i = 0;',
code => 'while (++$i % 4) {}',
},
+
+
+ 'regex::anyof_plus::anchored' => {
+ desc => '/^[acgt]+/',
+ setup => '$_ = "a" x 100;',
+ code => '/^[acgt]+/',
+ },
+ 'regex::anyof_plus::floating' => {
+ desc => '/[acgt]+where match starts at position 0 for 100 chars/',
+ setup => '$_ = "a" x 100;',
+ code => '/[acgt]+/',
+ },
+ 'regex::anyof_plus::floating_away' => {
+ desc => '/[acgt]+/ where match starts at position 100 for 100 chars',
+ setup => '$_ = ("0" x 100) . ("a" x 100);',
+ code => '/[acgt]+/',
+ },
];