From 47d9e282d43a5ac38578d75ae04b3d98b85f4c81 Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Mon, 16 Sep 2019 19:23:18 +0200 Subject: [PATCH] SDK: Replace for loop with count_if --- fairmq/sdk/Topology.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fairmq/sdk/Topology.h b/fairmq/sdk/Topology.h index 93e993ed..e3f112e6 100644 --- a/fairmq/sdk/Topology.h +++ b/fairmq/sdk/Topology.h @@ -9,6 +9,7 @@ #ifndef FAIR_MQ_SDK_TOPOLOGY_H #define FAIR_MQ_SDK_TOPOLOGY_H +#include #include #include #include @@ -450,12 +451,9 @@ class BasicTopology : public AsioBase /// call only under locked fMtx! auto ResetTransitionedCount(DeviceState targetState) -> void { - fTransitionedCount = 0; - for (const auto& s : fState) { - if (s.second.state == targetState) { - ++fTransitionedCount; - } - } + fTransitionedCount = std::count_if(fState.cbegin(), fState.cend(), [=](const auto& s) { + return s.second.state == targetState; + }); } /// call only under locked fMtx!