diff --git a/Userland/Libraries/LibRegex/RegexByteCode.cpp b/Userland/Libraries/LibRegex/RegexByteCode.cpp index 7532d67132..c109ce301e 100644 --- a/Userland/Libraries/LibRegex/RegexByteCode.cpp +++ b/Userland/Libraries/LibRegex/RegexByteCode.cpp @@ -181,28 +181,6 @@ void ByteCode::ensure_opcodes_initialized() s_opcodes_initialized = true; } -ALWAYS_INLINE OpCode& ByteCode::get_opcode_by_id(OpCodeId id) const -{ - VERIFY(id >= OpCodeId::First && id <= OpCodeId::Last); - - auto& opcode = s_opcodes[(u32)id]; - opcode->set_bytecode(*const_cast(this)); - return *opcode; -} - -OpCode& ByteCode::get_opcode(MatchState& state) const -{ - OpCodeId opcode_id; - if (auto opcode_ptr = static_cast const&>(*this).find(state.instruction_position)) - opcode_id = (OpCodeId)*opcode_ptr; - else - opcode_id = OpCodeId::Exit; - - auto& opcode = get_opcode_by_id(opcode_id); - opcode.set_state(state); - return opcode; -} - ALWAYS_INLINE ExecutionResult OpCode_Exit::execute(MatchInput const& input, MatchState& state) const { if (state.string_position > input.view.length() || state.instruction_position >= m_bytecode->size()) diff --git a/Userland/Libraries/LibRegex/RegexByteCode.h b/Userland/Libraries/LibRegex/RegexByteCode.h index 46f50a9eb0..38aba05d93 100644 --- a/Userland/Libraries/LibRegex/RegexByteCode.h +++ b/Userland/Libraries/LibRegex/RegexByteCode.h @@ -822,6 +822,28 @@ public: } }; +ALWAYS_INLINE OpCode& ByteCode::get_opcode(regex::MatchState& state) const +{ + OpCodeId opcode_id; + if (auto opcode_ptr = static_cast const&>(*this).find(state.instruction_position)) + opcode_id = (OpCodeId)*opcode_ptr; + else + opcode_id = OpCodeId::Exit; + + auto& opcode = get_opcode_by_id(opcode_id); + opcode.set_state(state); + return opcode; +} + +ALWAYS_INLINE OpCode& ByteCode::get_opcode_by_id(OpCodeId id) const +{ + VERIFY(id >= OpCodeId::First && id <= OpCodeId::Last); + + auto& opcode = s_opcodes[(u32)id]; + opcode->set_bytecode(*const_cast(this)); + return *opcode; +} + template bool is(OpCode const&);