From 60731db626c072943cb35df993ab20902f7eaa72 Mon Sep 17 00:00:00 2001 From: Curve Date: Sat, 19 Aug 2023 14:48:24 +0200 Subject: [PATCH] refactor: prefer `static` constexpr --- private/constants.hpp | 2 +- src/disasm.cpp | 4 ++-- src/hooks.hook.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/private/constants.hpp b/private/constants.hpp index 12aa83c..bedb1e0 100644 --- a/private/constants.hpp +++ b/private/constants.hpp @@ -9,7 +9,7 @@ namespace lime x64, }; - constexpr inline architecture arch = (sizeof(std::uintptr_t)) == 8 ? architecture::x64 : architecture::x86; + static constexpr inline architecture arch = (sizeof(std::uintptr_t)) == 8 ? architecture::x64 : architecture::x86; enum size : std::size_t { diff --git a/src/disasm.cpp b/src/disasm.cpp index 6bca03d..9c77415 100644 --- a/src/disasm.cpp +++ b/src/disasm.cpp @@ -10,7 +10,7 @@ namespace lime { //? Max Instruction size on x86_64 - constexpr inline auto instruction_size = 0x15; + static constexpr inline auto instruction_size = 0x15; auto get_decoder = []() { ZydisDecoder decoder; @@ -124,7 +124,7 @@ namespace lime assert(((void)"Failed to decode instruction", false)); } - constexpr auto size = sizeof(instruction.raw.imm) / sizeof(instruction.raw.imm[0]); + static constexpr auto size = sizeof(instruction.raw.imm) / sizeof(instruction.raw.imm[0]); std::vector rtn; rtn.reserve(size); diff --git a/src/hooks.hook.cpp b/src/hooks.hook.cpp index a915db1..6b93087 100644 --- a/src/hooks.hook.cpp +++ b/src/hooks.hook.cpp @@ -172,7 +172,7 @@ namespace lime bool hook_base::impl::build_trampoline() { - constexpr auto prot = protection::read | protection::write | protection::execute; + static constexpr auto prot = protection::read | protection::write | protection::execute; auto near = !can_relocate_far(); auto size = estimate_size(near);