summaryrefslogtreecommitdiff
path: root/src/regex_impl.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-02-19 11:46:17 +1100
committerMaxime Coste <mawww@kakoune.org>2023-02-19 11:46:17 +1100
commit2b74cd4b598eab8b4688157c50b8968e377cb1d3 (patch)
treedb85b766f49daca7cbba11702ed29a16798d09ee /src/regex_impl.hh
parentf115af7a572dd28dc757031256c49796b3a6d8e6 (diff)
Remove instructions from ExecConfig
We can just compute whenever we reset last_step, which does not happen often and we know `forward` at compile time anyway
Diffstat (limited to 'src/regex_impl.hh')
-rw-r--r--src/regex_impl.hh14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/regex_impl.hh b/src/regex_impl.hh
index 48788094..d0c11c5d 100644
--- a/src/regex_impl.hh
+++ b/src/regex_impl.hh
@@ -249,17 +249,12 @@ public:
constexpr bool search = (mode & RegexMode::Search);
- ConstArrayView<CompiledRegex::Instruction> instructions{m_program.instructions};
- instructions = forward ? instructions.subrange(0, m_program.first_backward_inst)
- : instructions.subrange(m_program.first_backward_inst);
-
const ExecConfig config{
Sentinel{forward ? begin : end},
Sentinel{forward ? end : begin},
Sentinel{subject_begin},
Sentinel{subject_end},
- flags,
- instructions
+ flags
};
Iterator start = forward ? begin : end;
@@ -353,7 +348,6 @@ private:
const Sentinel subject_begin;
const Sentinel subject_end;
const RegexExecFlags flags;
- ConstArrayView<CompiledRegex::Instruction> instructions;
};
// Steps a thread until it consumes the current character, matches or fail
@@ -483,7 +477,11 @@ private:
if (++current_step == 0)
{
// We wrapped, avoid potential collision on inst.last_step by resetting them
- for (auto& inst : config.instructions)
+ ConstArrayView<CompiledRegex::Instruction> instructions{m_program.instructions};
+ instructions = forward ? instructions.subrange(0, m_program.first_backward_inst)
+ : instructions.subrange(m_program.first_backward_inst);
+
+ for (auto& inst : instructions)
inst.last_step = 0;
current_step = 1; // step 0 is never valid
}