mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibRegex: Transform 0,1 min/unbounded max repetitions to * or +
The implementation of transform_bytecode_repetition_min_max expects at least min=1, so let's also optimise on our way out of a bug where 'x{0,}' would cause a crash.
This commit is contained in:
parent
ec43f7a2b0
commit
b9ffa0ad2e
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/b9ffa0ad2e8 Pull-request: https://github.com/SerenityOS/serenity/pull/10411
|
@ -341,6 +341,13 @@ public:
|
|||
template<typename T>
|
||||
static void transform_bytecode_repetition_min_max(ByteCode& bytecode_to_repeat, T minimum, Optional<T> maximum, size_t min_repetition_mark_id, size_t max_repetition_mark_id, bool greedy = true) requires(IsIntegral<T>)
|
||||
{
|
||||
if (!maximum.has_value()) {
|
||||
if (minimum == 0)
|
||||
return transform_bytecode_repetition_any(bytecode_to_repeat, greedy);
|
||||
if (minimum == 1)
|
||||
return transform_bytecode_repetition_min_one(bytecode_to_repeat, greedy);
|
||||
}
|
||||
|
||||
ByteCode new_bytecode;
|
||||
new_bytecode.insert_bytecode_repetition_n(bytecode_to_repeat, minimum, min_repetition_mark_id);
|
||||
|
||||
|
|
Loading…
Reference in a new issue