From 95b849d05d05ae9e55eb839508536d5af314d331 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Wed, 10 Dec 2025 15:20:25 -0800 Subject: Use bn::base::function_ref instead of std::function for parameters that are not stored This avoids the overhead of constructing a `std::function`, which may require a heap allocation, when calling functions that immediately invokes a function object. --- mediumlevelilinstruction.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'mediumlevelilinstruction.h') diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h index b3965a63..97e44a81 100644 --- a/mediumlevelilinstruction.h +++ b/mediumlevelilinstruction.h @@ -20,9 +20,6 @@ #pragma once -#include -#include -#include #ifdef BINARYNINJACORE_LIBRARY #include "constantdata.h" #include "variable.h" @@ -31,6 +28,11 @@ #include "binaryninjaapi.h" #endif +#include "base/function_ref.h" + +#include +#include + #ifdef BINARYNINJACORE_LIBRARY namespace BinaryNinjaCore #else @@ -617,11 +619,11 @@ namespace BinaryNinja MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t expr, size_t instrIdx); MediumLevelILInstruction(const MediumLevelILInstructionBase& instr); - void VisitExprs(const std::function& func) const; + void VisitExprs(bn::base::function_ref func) const; ExprId CopyTo(MediumLevelILFunction* dest, const ILSourceLocation& sourceLocation = {}) const; ExprId CopyTo(MediumLevelILFunction* dest, - const std::function& subExprHandler, + bn::base::function_ref subExprHandler, const ILSourceLocation& sourceLocation = {}) const; // Templated accessors for instruction operands, use these for efficient access to a known instruction -- cgit v1.3.1