diff options
author | Lenny Maiorani <lenny@serenityos.org> | 2022-03-13 16:09:41 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-18 19:58:57 +0100 |
commit | f912a48315c425ff49fb9421f58ea5bb834a96d6 (patch) | |
tree | 3a07abae47052211701d97e0246d62f162adb295 /Userland/Libraries/LibX86 | |
parent | 31515a9147459d29f871d8dedfdc9a4072a9900d (diff) | |
download | serenity-f912a48315c425ff49fb9421f58ea5bb834a96d6.zip |
Userland: Change static const variables to static constexpr
`static const` variables can be computed and initialized at run-time
during initialization or the first time a function is called. Change
them to `static constexpr` to ensure they are computed at
compile-time.
This allows some removal of `strlen` because the length of the
`StringView` can be used which is pre-computed at compile-time.
Diffstat (limited to 'Userland/Libraries/LibX86')
-rw-r--r-- | Userland/Libraries/LibX86/Instruction.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibX86/Instruction.h b/Userland/Libraries/LibX86/Instruction.h index f9b920af58..60a797091e 100644 --- a/Userland/Libraries/LibX86/Instruction.h +++ b/Userland/Libraries/LibX86/Instruction.h @@ -29,9 +29,9 @@ protected: template<typename T> struct TypeTrivia { - static const size_t bits = sizeof(T) * 8; - static const T sign_bit = 1 << (bits - 1); - static const T mask = MakeUnsigned<T>(-1); + static constexpr size_t bits = sizeof(T) * 8; + static constexpr T sign_bit = 1 << (bits - 1); + static constexpr T mask = MakeUnsigned<T>(-1); }; template<typename T, typename U> @@ -189,7 +189,7 @@ enum InstructionFormat { OP_NEAR_imm, }; -static const unsigned CurrentAddressSize = 0xB33FBABE; +static constexpr unsigned CurrentAddressSize = 0xB33FBABE; struct InstructionDescriptor { InstructionHandler handler { nullptr }; |