summaryrefslogtreecommitdiff
path: root/highlevelilinstruction.h
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-12-10 15:20:25 -0800
committerMark Rowe <mark@vector35.com>2025-12-15 20:25:23 -0800
commit95b849d05d05ae9e55eb839508536d5af314d331 (patch)
treef06fc6ea5c13cc4972fe8b9fdd5c30d94779b045 /highlevelilinstruction.h
parent2f1150703636b2b06d84bb66853fce7382bf6f29 (diff)
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.
Diffstat (limited to 'highlevelilinstruction.h')
-rw-r--r--highlevelilinstruction.h19
1 files changed, 11 insertions, 8 deletions
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 <functional>
-#include <unordered_map>
-#include <vector>
+#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 <unordered_map>
+#include <vector>
+
#include <fmt/core.h>
#ifdef BINARYNINJACORE_LIBRARY
@@ -480,13 +483,13 @@ namespace BinaryNinja
HighLevelILInstruction(const HighLevelILInstructionBase& instr);
void CollectSubExprs(_STD_STACK<size_t>& toProcess) const;
- void VisitExprs(const std::function<bool(const HighLevelILInstruction& expr)>& func) const;
- void VisitExprs(const std::function<bool(const HighLevelILInstruction& expr)>& preFunc,
- const std::function<void(const HighLevelILInstruction& expr)>& postFunc) const;
+ void VisitExprs(bn::base::function_ref<bool(const HighLevelILInstruction& expr)> func) const;
+ void VisitExprs(bn::base::function_ref<bool(const HighLevelILInstruction& expr)> preFunc,
+ bn::base::function_ref<void(const HighLevelILInstruction& expr)> postFunc) const;
ExprId CopyTo(HighLevelILFunction* dest, const ILSourceLocation& sourceLocation = {}) const;
ExprId CopyTo(HighLevelILFunction* dest,
- const std::function<ExprId(const HighLevelILInstruction& subExpr)>& subExprHandler,
+ bn::base::function_ref<ExprId(const HighLevelILInstruction& subExpr)> subExprHandler,
const ILSourceLocation& sourceLocation = {}) const;
bool operator<(const HighLevelILInstruction& other) const;