Reverted a removed optimization.

This commit is contained in:
Leon Styhre 2020-12-17 00:20:25 +01:00
parent b6f15cb8d9
commit 5208150749

View file

@ -16,7 +16,6 @@
#include "utils/StringUtil.h"
#include "Log.h"
#include <algorithm>
#include <pugixml.hpp>
#include <string.h>
@ -172,5 +171,19 @@ const bool MameNames::isDevice(const std::string& _deviceName)
const bool MameNames::find(std::vector<std::string> 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;
}