summaryrefslogtreecommitdiff
path: root/redfish-core/src/registries.cpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-08-07 04:12:20 +0300
committerEd Tanous <ed@tanous.net>2023-08-21 22:29:33 +0300
commit3544d2a719c8bb7b07f9a39f61a3770ec84b909f (patch)
treedcce5cb8ee0219d04eea93d3f639f62e1f1c05a1 /redfish-core/src/registries.cpp
parent5ab47856f8499a5d2d393d1584b8fc402399eddf (diff)
downloadbmcweb-3544d2a719c8bb7b07f9a39f61a3770ec84b909f.tar.xz
Use ranges
C++20 brought us std::ranges for a lot of algorithms. Most of these conversions were done using comby, similar to: ``` comby -verbose 'std::lower_bound(:[a].begin(),:[b].end(),:[c])' 'std::ranges::lower_bound(:[a], :[c])' $(git ls-files | grep "\.[hc]\(pp\)\?$") -in-place ``` Change-Id: I0c99c04e9368312555c08147d474ca93a5959e8d Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'redfish-core/src/registries.cpp')
-rw-r--r--redfish-core/src/registries.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/redfish-core/src/registries.cpp b/redfish-core/src/registries.cpp
index 3bfe0591d0..e465b1584c 100644
--- a/redfish-core/src/registries.cpp
+++ b/redfish-core/src/registries.cpp
@@ -4,6 +4,7 @@
#include "registries/openbmc_message_registry.hpp"
#include "str_utility.hpp"
+#include <ranges>
#include <string>
#include <vector>
@@ -13,10 +14,9 @@ namespace redfish::registries
const Message* getMessageFromRegistry(const std::string& messageKey,
std::span<const MessageEntry> registry)
{
- std::span<const MessageEntry>::iterator messageIt =
- std::find_if(registry.begin(), registry.end(),
- [&messageKey](const MessageEntry& messageEntry) {
- return std::strcmp(messageEntry.first, messageKey.c_str()) == 0;
+ std::span<const MessageEntry>::iterator messageIt = std::ranges::find_if(
+ registry, [&messageKey](const MessageEntry& messageEntry) {
+ return std::strcmp(messageEntry.first, messageKey.c_str()) == 0;
});
if (messageIt != registry.end())
{