read_fru_data: use std::find_if instead of raw loop
Use std::find_if to find matching item instead of using a raw loop.
Change-Id: I1814d66dc8c6b33cb8ea12317105dfa70c47fe60
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index ee9ad41..4723308 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -6,6 +6,7 @@
#include <host-ipmid/ipmid-api.h>
+#include <algorithm>
#include <map>
#include <phosphor-logging/elog-errors.hpp>
#include <sdbusplus/message/types.hpp>
@@ -82,17 +83,13 @@
}
for (auto& fru : frus)
{
- bool found = false;
auto& instanceList = fru.second;
- for (auto& instance : instanceList)
- {
- if (instance.path == path)
- {
- found = true;
- break;
- }
- }
- if (found)
+
+ auto found = std::find_if(
+ instanceList.begin(), instanceList.end(),
+ [&path](const auto& iter) { return (iter.path == path); });
+
+ if (found != instanceList.end())
{
auto& fruId = fru.first;