Просмотр исходного кода

LibJS/Bytecode: Make Bytecode::Register constexpr

A trivial change for 2% speed-up on Kraken/ai-astar.js :^)
Andreas Kling 2 лет назад
Родитель
Сommit
acd8c94e88
1 измененных файлов с 5 добавлено и 6 удалено
  1. 5 6
      Userland/Libraries/LibJS/Bytecode/Register.h

+ 5 - 6
Userland/Libraries/LibJS/Bytecode/Register.h

@@ -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;