SDK: Replace for loop with count_if

This commit is contained in:
Dennis Klein 2019-09-16 19:23:18 +02:00 committed by Alexey Rybalchenko
parent 23423a86d9
commit 47d9e282d4

View File

@ -9,6 +9,7 @@
#ifndef FAIR_MQ_SDK_TOPOLOGY_H
#define FAIR_MQ_SDK_TOPOLOGY_H
#include <algorithm>
#include <asio/async_result.hpp>
#include <asio/associated_executor.hpp>
#include <asio/steady_timer.hpp>
@ -450,12 +451,9 @@ class BasicTopology : public AsioBase<Executor, Allocator>
/// 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!