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. --- highlevelilinstruction.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'highlevelilinstruction.h') diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h index 84afeb98..083fed5d 100644 --- a/highlevelilinstruction.h +++ b/highlevelilinstruction.h @@ -20,16 +20,19 @@ #pragma once -#include -#include -#include +#include "base/function_ref.h" +#include "mediumlevelilinstruction.h" + #ifdef BINARYNINJACORE_LIBRARY #include "variable.h" #include "ilsourcelocation.h" #else #include "binaryninjaapi.h" #endif -#include "mediumlevelilinstruction.h" + +#include +#include + #include #ifdef BINARYNINJACORE_LIBRARY @@ -480,13 +483,13 @@ namespace BinaryNinja HighLevelILInstruction(const HighLevelILInstructionBase& instr); void CollectSubExprs(_STD_STACK& toProcess) const; - void VisitExprs(const std::function& func) const; - void VisitExprs(const std::function& preFunc, - const std::function& postFunc) const; + void VisitExprs(bn::base::function_ref func) const; + void VisitExprs(bn::base::function_ref preFunc, + bn::base::function_ref postFunc) const; ExprId CopyTo(HighLevelILFunction* dest, const ILSourceLocation& sourceLocation = {}) const; ExprId CopyTo(HighLevelILFunction* dest, - const std::function& subExprHandler, + bn::base::function_ref subExprHandler, const ILSourceLocation& sourceLocation = {}) const; bool operator<(const HighLevelILInstruction& other) const; -- cgit v1.3.1