@@ -21,16 +21,18 @@ using dds::network::request_shutdown;
2121
2222namespace {
2323// NOLINTNEXTLINE(cert-err58-cpp,fuchsia-statically-constructed-objects)
24- const std::map <std::string_view, request_id> mapping = {
25- {client_init::request::name, client_init::request::id},
24+ constexpr std::array <std::pair<std:: string_view, request_id>, 5 > mapping = {
25+ std::pair {client_init::request::name, client_init::request::id},
2626 {request_init::request::name, request_init::request::id},
2727 {request_exec::request::name, request_exec::request::id},
2828 {config_sync::request::name, config_sync::request::id},
2929 {request_shutdown::request::name, request_shutdown::request::id}};
3030
31- request_id command_name_to_id (const std::string & str)
31+ request_id command_name_to_id (std::string_view str)
3232{
33- auto it = mapping.find (str);
33+ // NOLINTNEXTLINE(modernize-use-ranges,boost-use-ranges)
34+ const auto *it = std::find_if (mapping.begin (), mapping.end (),
35+ [str](const auto &p) { return p.first == str; });
3436 return (it == mapping.end () ? request_id::unknown : it->second );
3537}
3638
0 commit comments