LibRegex: Treat checks against nonexistent checkpoints as empty

Due to optimiser shenanigans in the tree alternative form, some
JumpNonEmpty ops might be moved before their Checkpoint instruction.
It is safe to assume the distance between the nonexistent checkpoint and
the current op is zero, so just do that.
This commit is contained in:
Ali Mohammad Pur 2024-12-10 23:34:29 +01:00 committed by Ali Mohammad Pur
commit eee90f4aa2
Notes: github-actions[bot] 2024-12-13 09:01:16 +00:00
2 changed files with 3 additions and 1 deletions

View file

@ -1085,7 +1085,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Checkpoint::execute(MatchInput const&, Matc
ALWAYS_INLINE ExecutionResult OpCode_JumpNonEmpty::execute(MatchInput const& input, MatchState& state) const
{
u64 current_position = state.string_position;
auto checkpoint_position = state.checkpoints[checkpoint()];
auto checkpoint_position = state.checkpoints.get(checkpoint()).value_or(0);
if (checkpoint_position != 0 && checkpoint_position != current_position + 1) {
auto form = this->form();