Skip to content

Commit

Permalink
refactor: prefer static constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Aug 19, 2023
1 parent 6eebfee commit 60731db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion private/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<lime::imm> rtn;
rtn.reserve(size);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks.hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 60731db

Please sign in to comment.