From 4c8fa3972ad50c07631418620eb9be44d629b2ae Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Mon, 20 Oct 2025 23:28:36 -0700 Subject: Move implementations of key functions on Variable and SSAVariable to headers These types are heavily used as map keys so allowing the compiler to inline these functions makes map lookups cheaper. --- binaryninjaapi.h | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 90ee2585..9e90eeb8 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -10048,17 +10048,38 @@ namespace BinaryNinja { */ struct Variable : public BNVariable { - Variable(); - Variable(BNVariableSourceType type, uint32_t index, uint64_t storage); - Variable(BNVariableSourceType type, uint64_t storage); - Variable(const BNVariable& var); - Variable(const Variable& var); + Variable() : BNVariable{RegisterVariableSourceType, 0, 0} {} + Variable(BNVariableSourceType type, uint64_t storage) : Variable(type, 0, storage) {} + Variable(BNVariableSourceType type, uint32_t index, uint64_t storage) + : BNVariable{type, index, static_cast(storage)} + { + } + Variable(const BNVariable& var) : BNVariable(var) {} + + Variable(const Variable&) = default; + Variable& operator=(const Variable&) = default; - Variable& operator=(const Variable& var); + Variable(Variable&&) = default; + Variable& operator=(Variable&&) = default; + + bool operator==(const Variable& var) const + { + return type == var.type && index == var.index && storage == var.storage; + } - bool operator==(const Variable& var) const; - bool operator!=(const Variable& var) const; - bool operator<(const Variable& var) const; + bool operator!=(const Variable& var) const + { + return !(*this == var); + } + + bool operator<(const Variable& var) const + { + if (type != var.type) + return type < var.type; + if (storage != var.storage) + return storage < var.storage; + return index < var.index; + } uint64_t ToIdentifier() const; static Variable FromIdentifier(uint64_t id); -- cgit v1.3.1