mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibRegex: Avoid prepending items to vectors
This commit is contained in:
parent
214410b397
commit
794dc368f1
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)
|
if (recursion_level > c_max_recursion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Vector<MatchState> fork_low_prio_states;
|
Vector<MatchState, 64> reversed_fork_low_prio_states;
|
||||||
MatchState fork_high_prio_state;
|
MatchState fork_high_prio_state;
|
||||||
Optional<bool> success;
|
Optional<bool> success;
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case ExecutionResult::Fork_PrioLow:
|
case ExecutionResult::Fork_PrioLow:
|
||||||
fork_low_prio_states.prepend(state);
|
reversed_fork_low_prio_states.append(state);
|
||||||
continue;
|
continue;
|
||||||
case ExecutionResult::Fork_PrioHigh:
|
case ExecutionResult::Fork_PrioHigh:
|
||||||
fork_high_prio_state = state;
|
fork_high_prio_state = state;
|
||||||
|
@ -344,8 +344,13 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
|
||||||
return true;
|
return true;
|
||||||
case ExecutionResult::Failed:
|
case ExecutionResult::Failed:
|
||||||
return false;
|
return false;
|
||||||
case ExecutionResult::Failed_ExecuteLowPrioForks:
|
case ExecutionResult::Failed_ExecuteLowPrioForks: {
|
||||||
return execute_low_prio_forks(input, state, output, fork_low_prio_states, recursion_level + 1);
|
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