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
This commit is contained in:
parent
f115af7a57
commit
2b74cd4b59
|
@ -249,17 +249,12 @@ public:
|
||||||
|
|
||||||
constexpr bool search = (mode & RegexMode::Search);
|
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{
|
const ExecConfig config{
|
||||||
Sentinel{forward ? begin : end},
|
Sentinel{forward ? begin : end},
|
||||||
Sentinel{forward ? end : begin},
|
Sentinel{forward ? end : begin},
|
||||||
Sentinel{subject_begin},
|
Sentinel{subject_begin},
|
||||||
Sentinel{subject_end},
|
Sentinel{subject_end},
|
||||||
flags,
|
flags
|
||||||
instructions
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Iterator start = forward ? begin : end;
|
Iterator start = forward ? begin : end;
|
||||||
|
@ -353,7 +348,6 @@ private:
|
||||||
const Sentinel subject_begin;
|
const Sentinel subject_begin;
|
||||||
const Sentinel subject_end;
|
const Sentinel subject_end;
|
||||||
const RegexExecFlags flags;
|
const RegexExecFlags flags;
|
||||||
ConstArrayView<CompiledRegex::Instruction> instructions;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Steps a thread until it consumes the current character, matches or fail
|
// Steps a thread until it consumes the current character, matches or fail
|
||||||
|
@ -483,7 +477,11 @@ private:
|
||||||
if (++current_step == 0)
|
if (++current_step == 0)
|
||||||
{
|
{
|
||||||
// We wrapped, avoid potential collision on inst.last_step by resetting them
|
// 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;
|
inst.last_step = 0;
|
||||||
current_step = 1; // step 0 is never valid
|
current_step = 1; // step 0 is never valid
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user