Repository navigation
Commit fa2f77c
committed
Avoid copying MetricFamily in Family::Collect
Collect() built the family in a local variable and returned it as
`return {family};`. A braced-init-list copies its elements, so every
collection deep-copied the whole metric vector, including each
ClientMetric and all of its labels, and temporarily required twice the
memory of the collected family.
Move the family into the returned vector instead. Registry::Collect()
already moves the families out, so this removes the last copy on the
collection path.
Relates to #741.1 parent e0cbaed commit fa2f77c
1 file changed
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
92 | 93 | | |
93 | | - | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | | - | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | | - | |
| 105 | + | |
| 106 | + | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
| |||
0 commit comments