1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

LibRegex: Make get_opcode() return a reference

Previously this would return a pointer which could be null if the
requested opcode was invalid. This should never be the case though
so let's VERIFY() that instead.
This commit is contained in:
Gunnar Beutner 2021-06-13 22:18:54 +02:00 committed by Ali Mohammad Pur
parent cd49fb0229
commit 281f39073d
4 changed files with 24 additions and 37 deletions

View file

@ -301,15 +301,10 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
for (;;) {
++output.operations;
auto* opcode = bytecode.get_opcode(state);
if (!opcode) {
dbgln("Wrong opcode... failed!");
return {};
}
auto& opcode = bytecode.get_opcode(state);
#if REGEX_DEBUG
s_regex_dbg.print_opcode("VM", *opcode, state, recursion_level, false);
s_regex_dbg.print_opcode("VM", opcode, state, recursion_level, false);
#endif
ExecutionResult result;
@ -317,14 +312,14 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
--input.fail_counter;
result = ExecutionResult::Failed_ExecuteLowPrioForks;
} else {
result = opcode->execute(input, state, output);
result = opcode.execute(input, state, output);
}
#if REGEX_DEBUG
s_regex_dbg.print_result(*opcode, bytecode, input, state, result);
s_regex_dbg.print_result(opcode, bytecode, input, state, result);
#endif
state.instruction_position += opcode->size();
state.instruction_position += opcode.size();
switch (result) {
case ExecutionResult::Fork_PrioLow: