From 87d53be505ac8046b8dd65a346af15dfbccdf2c7 Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Fri, 22 Jul 2016 06:56:14 -0400 Subject: [PATCH] Added a usage of std::find_if() in softlist --- src/emu/softlist.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/emu/softlist.cpp b/src/emu/softlist.cpp index 0c72186454d..c9f0f2d9cc1 100644 --- a/src/emu/softlist.cpp +++ b/src/emu/softlist.cpp @@ -519,13 +519,20 @@ const software_info *software_list_device::find(const char *look_for) bool iswild = strchr(look_for, '*') != nullptr || strchr(look_for, '?'); // find a match (will cause a parse if needed when calling get_info) - for (const software_info &info : get_info()) - { - if ((iswild && core_strwildcmp(look_for, info.shortname().c_str()) == 0) || core_stricmp(look_for, info.shortname().c_str()) == 0) - return &info; - } + const auto &info_list = get_info(); + auto iter = std::find_if( + info_list.begin(), + info_list.end(), + [&](const software_info &info) + { + const char *shortname = info.shortname().c_str(); + return (iswild && core_strwildcmp(look_for, shortname) == 0) + || core_stricmp(look_for, shortname) == 0; + }); - return nullptr; + return iter != info_list.end() + ? &*iter + : nullptr; }