@@ -74,9 +74,10 @@ class AttributesHashMapWithCustomHash
74
74
* If not present, it uses the provided callback to generate
75
75
* value and store in the hash
76
76
*/
77
- Aggregation *GetOrSetDefault (const opentelemetry::common::KeyValueIterable &attributes,
78
- const AttributesProcessor *attributes_processor,
79
- std::function<std::unique_ptr<Aggregation>()> aggregation_callback)
77
+ Aggregation *GetOrSetDefault (
78
+ const opentelemetry::common::KeyValueIterable &attributes,
79
+ const AttributesProcessor *attributes_processor,
80
+ nostd::function_ref<std::unique_ptr<Aggregation>()> aggregation_callback)
80
81
{
81
82
// TODO: avoid constructing MetricAttributes from KeyValueIterable for
82
83
// hash_map_.find which is a heavy operation
@@ -97,8 +98,9 @@ class AttributesHashMapWithCustomHash
97
98
return result.first ->second .get ();
98
99
}
99
100
100
- Aggregation *GetOrSetDefault (const MetricAttributes &attributes,
101
- std::function<std::unique_ptr<Aggregation>()> aggregation_callback)
101
+ Aggregation *GetOrSetDefault (
102
+ const MetricAttributes &attributes,
103
+ nostd::function_ref<std::unique_ptr<Aggregation>()> aggregation_callback)
102
104
{
103
105
auto it = hash_map_.find (attributes);
104
106
if (it != hash_map_.end ())
@@ -115,8 +117,9 @@ class AttributesHashMapWithCustomHash
115
117
return hash_map_[attributes].get ();
116
118
}
117
119
118
- Aggregation *GetOrSetDefault (MetricAttributes &&attributes,
119
- std::function<std::unique_ptr<Aggregation>()> aggregation_callback)
120
+ Aggregation *GetOrSetDefault (
121
+ MetricAttributes &&attributes,
122
+ nostd::function_ref<std::unique_ptr<Aggregation>()> aggregation_callback)
120
123
{
121
124
auto it = hash_map_.find (attributes);
122
125
if (it != hash_map_.end ())
@@ -207,7 +210,7 @@ class AttributesHashMapWithCustomHash
207
210
size_t attributes_limit_;
208
211
209
212
Aggregation *GetOrSetOveflowAttributes (
210
- std::function <std::unique_ptr<Aggregation>()> aggregation_callback)
213
+ nostd::function_ref <std::unique_ptr<Aggregation>()> aggregation_callback)
211
214
{
212
215
auto agg = aggregation_callback ();
213
216
return GetOrSetOveflowAttributes (std::move (agg));
0 commit comments