mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibRegex: Avoid prepending items to vectors
This commit is contained in:
parent
214410b397
commit
794dc368f1
Notes:
sideshowbarker
2024-07-18 12:15:24 +09:00
Author: https://github.com/gunnarbeutner
Commit: 794dc368f1
Pull-request: https://github.com/SerenityOS/serenity/pull/8044
Reviewed-by: https://github.com/alimpfard
1 changed files with 9 additions and 4 deletions
|
@ -293,7 +293,7 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
|
|||
if (recursion_level > c_max_recursion)
|
||||
return false;
|
||||
|
||||
Vector<MatchState> fork_low_prio_states;
|
||||
Vector<MatchState, 64> reversed_fork_low_prio_states;
|
||||
MatchState fork_high_prio_state;
|
||||
Optional<bool> success;
|
||||
|
||||
|
@ -323,7 +323,7 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
|
|||
|
||||
switch (result) {
|
||||
case ExecutionResult::Fork_PrioLow:
|
||||
fork_low_prio_states.prepend(state);
|
||||
reversed_fork_low_prio_states.append(state);
|
||||
continue;
|
||||
case ExecutionResult::Fork_PrioHigh:
|
||||
fork_high_prio_state = state;
|
||||
|
@ -344,8 +344,13 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
|
|||
return true;
|
||||
case ExecutionResult::Failed:
|
||||
return false;
|
||||
case ExecutionResult::Failed_ExecuteLowPrioForks:
|
||||
return execute_low_prio_forks(input, state, output, fork_low_prio_states, recursion_level + 1);
|
||||
case ExecutionResult::Failed_ExecuteLowPrioForks: {
|
||||
Vector<MatchState> fork_low_prio_states;
|
||||
fork_low_prio_states.ensure_capacity(reversed_fork_low_prio_states.size());
|
||||
for (ssize_t i = reversed_fork_low_prio_states.size() - 1; i >= 0; i--)
|
||||
fork_low_prio_states.unchecked_append(move(reversed_fork_low_prio_states[i]));
|
||||
return execute_low_prio_forks(input, state, output, move(fork_low_prio_states), recursion_level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue