1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibJS/Bytecode: Make Bytecode::Register constexpr

A trivial change for 2% speed-up on Kraken/ai-astar.js :^)
This commit is contained in:
Andreas Kling 2023-07-12 19:29:28 +02:00 committed by Jelle Raaijmakers
parent 3476cf0fcb
commit acd8c94e88

View file

@ -14,20 +14,19 @@ class Register {
public:
constexpr static u32 accumulator_index = 0;
static Register accumulator()
static constexpr Register accumulator()
{
static Register accumulator(accumulator_index);
return accumulator;
return Register(accumulator_index);
}
explicit Register(u32 index)
constexpr explicit Register(u32 index)
: m_index(index)
{
}
bool operator==(Register reg) const { return m_index == reg.index(); }
constexpr bool operator==(Register reg) const { return m_index == reg.index(); }
u32 index() const { return m_index; }
constexpr u32 index() const { return m_index; }
private:
u32 m_index;