diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-03-11 21:47:14 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-03-11 21:47:14 +1100 |
| commit | e06acd3dc89cc7ea560d6b404156493533243ed1 (patch) | |
| tree | b62452bff976b8853965fc128982e5543263ab2e /src | |
| parent | 84fc2844a1116799034317386ee45626a91ed153 (diff) | |
Simplify Split regex op handling by swapping target
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex_impl.hh | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 43db9a02..c33de312 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -408,18 +408,14 @@ private: thread.inst = inst.param.jump_target; break; case CompiledRegex::Split: - if (instructions[inst.param.split.target].last_step == current_step) - break; - - if (thread.saves >= 0) - ++m_saves[thread.saves].refcount; - - if (inst.param.split.prioritize_parent) - m_threads.push_current({inst.param.split.target, thread.saves}); - else + if (auto target = inst.param.split.target; + instructions[target].last_step != current_step) { - m_threads.push_current(thread); - thread.inst = inst.param.split.target; + if (thread.saves >= 0) + ++m_saves[thread.saves].refcount; + if (not inst.param.split.prioritize_parent) + std::swap(thread.inst, target); + m_threads.push_current({target, thread.saves}); } break; case CompiledRegex::Save: |
