Skip to content

Commit 445eaf5

Browse files
authored
DPL Analysis: avoid std::function in literal node (#5649)
A function pointer with a non-capturing lambda should be more than enough.
1 parent 628ea15 commit 445eaf5

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Framework/Core/include/Framework/Expressions.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ struct OpNode {
118118
/// A placeholder node for simple type configurable
119119
struct PlaceholderNode : LiteralNode {
120120
template <typename T>
121-
PlaceholderNode(Configurable<T> v) : LiteralNode{v.value}
121+
PlaceholderNode(Configurable<T> v) : LiteralNode{v.value}, name{v.name}
122122
{
123123
if constexpr (variant_trait_v<typename std::decay<T>::type> != VariantType::Unknown) {
124-
retrieve = [name = v.name](InitContext& context) { return LiteralNode::var_t{context.options().get<T>(name.c_str())}; };
124+
retrieve = [](InitContext& context, std::string const& name) { return LiteralNode::var_t{context.options().get<T>(name.c_str())}; };
125125
} else {
126-
retrieve = [name = v.name](InitContext& context) {
126+
retrieve = [](InitContext& context, std::string const& name) {
127127
auto pt = context.options().get<boost::property_tree::ptree>(name.c_str());
128128
return LiteralNode::var_t{RootConfigParamHelpers::as<T>(pt)};
129129
};
@@ -132,10 +132,11 @@ struct PlaceholderNode : LiteralNode {
132132

133133
void reset(InitContext& context)
134134
{
135-
value = retrieve(context);
135+
value = retrieve(context, name);
136136
}
137137

138-
std::function<LiteralNode::var_t(InitContext&)> retrieve;
138+
std::string name;
139+
LiteralNode::var_t (*retrieve)(InitContext&, std::string const& name);
139140
};
140141

141142
/// A generic tree node

0 commit comments

Comments
 (0)