Skip to content

Commit

Permalink
core: Move elememts from one vector to the final one
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Jul 3, 2019
1 parent 86360e1 commit 7fcba1f
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 7fcba1f

Please sign in to comment.