From 2b74cd4b598eab8b4688157c50b8968e377cb1d3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 19 Feb 2023 11:46:17 +1100 Subject: [PATCH] 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 --- src/regex_impl.hh | 14 ++++++-------- 1 file 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 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 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 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 }