mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 20:42:11 +02: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:
committed by
Linus Groh
parent
f0d2489254
commit
6a4c8a66ae
Notes:
sideshowbarker
2024-07-17 19:05:25 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/6a4c8a66ae Pull-request: https://github.com/SerenityOS/serenity/pull/12397
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user