summaryrefslogtreecommitdiff
path: root/Tests/LibRegex/Regex.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-02-04 23:56:44 +0330
committerAndreas Kling <kling@serenityos.org>2022-02-05 00:09:32 +0100
commita962ee020a6310b2d7c7479aa058c15484127418 (patch)
tree9c2b955cf5048c049e29283f1178280894936e36 /Tests/LibRegex/Regex.cpp
parent2b028f6faa3196f2498f29613f66ba374e6c253a (diff)
downloadserenity-a962ee020a6310b2d7c7479aa058c15484127418.zip
LibJS+LibRegex: Don't repeat regex match in regexp_exec()
LibRegex already implements this loop in a more performant way, so all LibJS has to do here is to return things in the right shape, and not loop over the input string. Previously this was a quadratic operation on string length, which lead to crazy execution times on failing regexps - now it's nice and fast :^) Note that a Regex test has to be updated to remove the stateful flag as it repeats matching on multiple strings.
Diffstat (limited to 'Tests/LibRegex/Regex.cpp')
-rw-r--r--Tests/LibRegex/Regex.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp
index 2e498811b5..c7e699c194 100644
--- a/Tests/LibRegex/Regex.cpp
+++ b/Tests/LibRegex/Regex.cpp
@@ -984,7 +984,9 @@ TEST_CASE(negative_lookahead)
{
{
// Negative lookahead with more than 2 forks difference between lookahead init and finish.
- Regex<ECMA262> re(":(?!\\^\\)|1)", ECMAScriptFlags::Global);
+ auto options = ECMAScriptOptions { ECMAScriptFlags::Global };
+ options.reset_flag((ECMAScriptFlags)regex::AllFlags::Internal_Stateful);
+ Regex<ECMA262> re(":(?!\\^\\)|1)", options);
EXPECT_EQ(re.match(":^)").success, false);
EXPECT_EQ(re.match(":1").success, false);
EXPECT_EQ(re.match(":foobar").success, true);