mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibRegex: Bail out of atomic rewrite if a block doesn't contain compares
If a block jumps before performing a compare, we'd need to recursively find the first of the jumped-to block. While this is doable, it's not really worth spending the time as most such cases won't actually qualify for atomic loop rewrite anyway. Fixes an invalid rewrite when `.+` is followed by an alternation, e.g. /.+(a|b|c)/.
This commit is contained in:
parent
af441bb939
commit
7f530c0753
2 changed files with 21 additions and 1 deletions
|
@ -986,6 +986,8 @@ TEST_CASE(optimizer_atomic_groups)
|
|||
Tuple { "a+"sv, ""sv, false },
|
||||
// 'y' and [^x] have an overlap ('y'), the loop should not be rewritten here.
|
||||
Tuple { "[^x]+y"sv, "ay"sv, true },
|
||||
// .+ should not be rewritten here, as it's followed by something that would be matched by `.`.
|
||||
Tuple { ".+(a|b|c)"sv, "xxa"sv, true },
|
||||
};
|
||||
|
||||
for (auto& test : tests) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue