diff options
Diffstat (limited to 'src/emu/drivenum.cpp')
-rw-r--r-- | src/emu/drivenum.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/emu/drivenum.cpp b/src/emu/drivenum.cpp index 989a9cc8f46..84158749189 100644 --- a/src/emu/drivenum.cpp +++ b/src/emu/drivenum.cpp @@ -10,11 +10,14 @@ #include "emu.h" #include "drivenum.h" + +#include "corestr.h" #include "softlist_dev.h" +#include "unicode.h" #include <algorithm> -#include <ctype.h> +#include <cctype> @@ -257,7 +260,7 @@ void driver_enumerator::find_approximate_matches(std::string const &string, std: { // allocate memory to track the penalty value std::vector<std::pair<double, int> > penalty; - penalty.reserve(count); + penalty.reserve(count + 1); std::u32string const search(ustr_from_utf8(normalize_unicode(string, unicode_normalization_form::D, true))); std::string composed; std::u32string candidate; @@ -300,9 +303,9 @@ void driver_enumerator::find_approximate_matches(std::string const &string, std: auto const it(std::upper_bound(penalty.begin(), penalty.end(), std::make_pair(curpenalty, index))); if (penalty.end() != it) { - if (penalty.size() >= count) - penalty.resize(count - 1); penalty.emplace(it, curpenalty, index); + if (penalty.size() > count) + penalty.pop_back(); } else if (penalty.size() < count) { @@ -340,7 +343,7 @@ void driver_enumerator::release_current() const if (cached != m_config.end()) { // iterate over software lists in this entry and reset - for (software_list_device &swlistdev : software_list_device_iterator(cached->second->root_device())) + for (software_list_device &swlistdev : software_list_device_enumerator(cached->second->root_device())) swlistdev.release(); } } |