Skip to content

Commit

Permalink
Merge pull request #285 from jupp0r/move-when-collecting
Browse files Browse the repository at this point in the history
core: Move elememts from one vector to the final one
  • Loading branch information
jupp0r committed Jul 3, 2019
2 parents 86360e1 + 7fcba1f commit d83dd68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/registry.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include "prometheus/registry.h"

#include <iterator>

namespace prometheus {

std::vector<MetricFamily> Registry::Collect() {
std::lock_guard<std::mutex> lock{mutex_};
auto results = std::vector<MetricFamily>{};
for (auto&& collectable : collectables_) {
auto metrics = collectable->Collect();
results.insert(results.end(), metrics.begin(), metrics.end());
results.insert(results.end(), std::make_move_iterator(metrics.begin()),
std::make_move_iterator(metrics.end()));
}

return results;
Expand Down

0 comments on commit d83dd68

Please sign in to comment.