mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibRegex: Only skip full instructions when optimizing alternations
It makes no sense to skip half of an instruction, so make sure to skip only full instructions!
This commit is contained in:
parent
f0d2489254
commit
6a4c8a66ae
2 changed files with 8 additions and 1 deletions
|
@ -484,7 +484,12 @@ void Optimizer::append_alternation(ByteCode& target, ByteCode&& left, ByteCode&&
|
|||
if (left.spans().slice(left_block.start, left_end - left_block.start) != right.spans().slice(right_block.start, right_end - right_block.start))
|
||||
break;
|
||||
|
||||
left_skip = left_end;
|
||||
state.instruction_position = 0;
|
||||
while (state.instruction_position < left_end) {
|
||||
auto& opcode = left.get_opcode(state);
|
||||
left_skip = state.instruction_position;
|
||||
state.instruction_position += opcode.size();
|
||||
}
|
||||
}
|
||||
|
||||
dbgln_if(REGEX_DEBUG, "Skipping {}/{} bytecode entries from {}/{}", left_skip, 0, left.size(), right.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue