1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 03:18:11 +00:00

LibRegex: Always inline get_opcode()

This function's prologue was showing up as very hot in profiles, taking
almost 9% of runtime in our Regex test suite.
This commit is contained in:
Ali Mohammad Pur 2023-07-28 20:54:44 +03:30 committed by Andreas Kling
parent a539c261b1
commit 11abca421a
2 changed files with 22 additions and 22 deletions

View file

@ -822,6 +822,28 @@ public:
}
};
ALWAYS_INLINE OpCode& ByteCode::get_opcode(regex::MatchState& state) const
{
OpCodeId opcode_id;
if (auto opcode_ptr = static_cast<DisjointChunks<ByteCodeValueType> 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<ByteCode*>(this));
return *opcode;
}
template<typename T>
bool is(OpCode const&);