diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-02-02 14:51:04 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-02-02 14:51:17 +1100 |
| commit | 33e81af0f3b6dff09903d2d3aaa36e7800941166 (patch) | |
| tree | 39e27cdacb37d4d90ff36c0033daa7470a5e6419 /src/regex_impl.hh | |
| parent | 0b29fcf32ac756dc54ec5c52db63340c9b3692e9 (diff) | |
Fix regex alternation execution priority
The ThreadedRegexVM implementation does not execute split opcodes as
expected: on split the pending thread is pushed on top of the thread
stack, which means that when multiple splits are executed in a row
(such as with a disjunction with 3 or more branches) the last split
target gets on top of the thread stack and gets executed next (when the
thread from the first split target would be the expected one)
Fixing this in the ThreadedRegexVM would have a performance impact as
we would not be able to use a plain stack for current threads, so the
best solution at the moment is to reverse the order of splits generated
by a disjunction.
Fixes #4519
Diffstat (limited to 'src/regex_impl.hh')
| -rw-r--r-- | src/regex_impl.hh | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 0565c49c..ca859592 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -113,8 +113,6 @@ struct CompiledRegex : RefCountable, UseMemoryDomain<MemoryDomain::Regex> }; static_assert(sizeof(Instruction) == 8); - static constexpr uint32_t prioritize_parent{1 << 16}; - explicit operator bool() const { return not instructions.empty(); } struct NamedCapture @@ -255,7 +253,7 @@ public: else if (start != config.end) { const unsigned char c = forward ? *start : *utf8::previous(start, config.end); - if (not start_desc->map[(c < StartDesc::count) ? c : StartDesc::other]) + if (not start_desc->map[(c < StartDesc::count) ? c : StartDesc::other]) return false; } } |
