From 26abdc367e92e95a69a9a4498986eab3c4e79048 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 2 Jul 2018 13:14:28 -0500 Subject: [PATCH] minor refactoring Change-Id: I1911ba4f12f8f961a3d8a9f524e849e0cdd9664f --- src/core/group_set.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/group_set.h b/src/core/group_set.h index b52e865cee..e5514e76f0 100644 --- a/src/core/group_set.h +++ b/src/core/group_set.h @@ -197,7 +197,7 @@ class MetricsGroupSet { private: void Initialize(const rocprofiler_feature_t* info_array, const uint32_t info_count) { - std::multimap input_metrics; + std::multimap > input_metrics; for (unsigned i = 0; i < info_count; ++i) { const rocprofiler_feature_t* info = &info_array[i]; if (info->kind != ROCPROFILER_FEATURE_KIND_METRIC) continue; @@ -209,22 +209,22 @@ class MetricsGroupSet { AQL_EXC_RAISING(HSA_STATUS_ERROR, "Metric '" << metric->GetName() << "' doesn't fit in one group"); } } - uint32_t group_num = 0; - while (input_metrics.size() != 0) { +#if 0 + for (const auto& entry : input_metrics) { + printf("%u %s\n", entry.first, entry.second->GetName().c_str()); + } +#endif + auto end = input_metrics.end(); + while (!input_metrics.empty()) { MetricsGroup* group = NextGroup(); - ++group_num; - auto it = input_metrics.end(); - --it; - bool to_cont = true; + auto it = input_metrics.begin(); do { - const Metric* metric = it->second; - const bool to_erase = (group->AddMetric(metric) == true); - to_cont = (it != input_metrics.begin()); - - auto curr = it; - if (to_cont) --it; - if (to_erase) input_metrics.erase(curr); - } while (to_cont); + auto curr = it++; + const Metric* metric = curr->second; + if (group->AddMetric(metric) == true) { + input_metrics.erase(curr); + } + } while (it != end); } }