From 5208150749eb4daa95343b3cc39a9e3253f2c0d6 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 17 Dec 2020 00:20:25 +0100 Subject: [PATCH] Reverted a removed optimization. --- es-core/src/MameNames.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/es-core/src/MameNames.cpp b/es-core/src/MameNames.cpp index d7d74300c..f1c19705a 100644 --- a/es-core/src/MameNames.cpp +++ b/es-core/src/MameNames.cpp @@ -16,7 +16,6 @@ #include "utils/StringUtil.h" #include "Log.h" -#include #include #include @@ -172,5 +171,19 @@ const bool MameNames::isDevice(const std::string& _deviceName) const bool MameNames::find(std::vector devices, const std::string& name) { - return (std::find(devices.begin(), devices.end(), name) != devices.end()); + size_t start = 0; + size_t end = devices.size(); + + while (start < end) { + const size_t index = (start + end) / 2; + const int compare = strcmp(devices[index].c_str(), name.c_str()); + + if (compare < 0) + start = index + 1; + else if (compare > 0) + end = index; + else + return true; + } + return false; }