diff --git a/common/HeterogeneousContainers.h b/common/HeterogeneousContainers.h index c569414f3f..9047225976 100644 --- a/common/HeterogeneousContainers.h +++ b/common/HeterogeneousContainers.h @@ -71,43 +71,6 @@ using UnorderedStringSet = using UnorderedStringMultiSet = std::unordered_multiset; -template -__fi typename UnorderedStringMap::const_iterator -UnorderedStringMapFind(const UnorderedStringMap& map, const KeyType& key) -{ - return map.find(key); -} -template -__fi typename UnorderedStringMap::iterator -UnorderedStringMapFind(UnorderedStringMap& map, const KeyType& key) -{ - return map.find(key); -} -template -__fi typename UnorderedStringMultimap::const_iterator -UnorderedStringMultiMapFind(const UnorderedStringMultimap& map, const KeyType& key) -{ - return map.find(key); -} -template -__fi std::pair::const_iterator, typename UnorderedStringMultimap::const_iterator> -UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap& map, const KeyType& key) -{ - return map.equal_range(key); -} -template -__fi typename UnorderedStringMultimap::iterator -UnorderedStringMultiMapFind(UnorderedStringMultimap& map, const KeyType& key) -{ - return map.find(key); -} -template -__fi std::pair::iterator, typename UnorderedStringMultimap::iterator> -UnorderedStringMultiMapEqualRange(UnorderedStringMultimap& map, const KeyType& key) -{ - return map.equal_range(key); -} - template using StringMap = std::map; template diff --git a/common/MemorySettingsInterface.cpp b/common/MemorySettingsInterface.cpp index 6b0cb95005..0192116e90 100644 --- a/common/MemorySettingsInterface.cpp +++ b/common/MemorySettingsInterface.cpp @@ -32,7 +32,7 @@ void MemorySettingsInterface::Clear() bool MemorySettingsInterface::GetIntValue(const char* section, const char* key, s32* value) const { - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit == m_sections.end()) return false; @@ -50,11 +50,11 @@ bool MemorySettingsInterface::GetIntValue(const char* section, const char* key, bool MemorySettingsInterface::GetUIntValue(const char* section, const char* key, u32* value) const { - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit == m_sections.end()) return false; - const auto iter = UnorderedStringMultiMapFind(sit->second, key); + const auto iter = sit->second.find(key); if (iter == sit->second.end()) return false; @@ -68,11 +68,11 @@ bool MemorySettingsInterface::GetUIntValue(const char* section, const char* key, bool MemorySettingsInterface::GetFloatValue(const char* section, const char* key, float* value) const { - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit == m_sections.end()) return false; - const auto iter = UnorderedStringMultiMapFind(sit->second, key); + const auto iter = sit->second.find(key); if (iter == sit->second.end()) return false; @@ -86,11 +86,11 @@ bool MemorySettingsInterface::GetFloatValue(const char* section, const char* key bool MemorySettingsInterface::GetDoubleValue(const char* section, const char* key, double* value) const { - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit == m_sections.end()) return false; - const auto iter = UnorderedStringMultiMapFind(sit->second, key); + const auto iter = sit->second.find(key); if (iter == sit->second.end()) return false; @@ -104,11 +104,11 @@ bool MemorySettingsInterface::GetDoubleValue(const char* section, const char* ke bool MemorySettingsInterface::GetBoolValue(const char* section, const char* key, bool* value) const { - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit == m_sections.end()) return false; - const auto iter = UnorderedStringMultiMapFind(sit->second, key); + const auto iter = sit->second.find(key); if (iter == sit->second.end()) return false; @@ -122,11 +122,11 @@ bool MemorySettingsInterface::GetBoolValue(const char* section, const char* key, bool MemorySettingsInterface::GetStringValue(const char* section, const char* key, std::string* value) const { - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit == m_sections.end()) return false; - const auto iter = UnorderedStringMultiMapFind(sit->second, key); + const auto iter = sit->second.find(key); if (iter == sit->second.end()) return false; @@ -167,7 +167,7 @@ void MemorySettingsInterface::SetStringValue(const char* section, const char* ke std::vector> MemorySettingsInterface::GetKeyValueList(const char* section) const { std::vector> output; - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); if (sit != m_sections.end()) { for (const auto& it : sit->second) @@ -178,7 +178,7 @@ std::vector> MemorySettingsInterface::GetKey void MemorySettingsInterface::SetKeyValueList(const char* section, const std::vector>& items) { - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); sit->second.clear(); for (const auto& [key, value] : items) sit->second.emplace(key, value); @@ -186,11 +186,11 @@ void MemorySettingsInterface::SetKeyValueList(const char* section, const std::ve void MemorySettingsInterface::SetValue(const char* section, const char* key, std::string value) { - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); if (sit == m_sections.end()) sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first; - const auto range = UnorderedStringMultiMapEqualRange(sit->second, key); + const auto range = sit->second.equal_range(key); if (range.first == sit->second.end()) { sit->second.emplace(std::string(key), std::move(value)); @@ -213,10 +213,10 @@ std::vector MemorySettingsInterface::GetStringList(const char* sect { std::vector ret; - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit != m_sections.end()) { - const auto range = UnorderedStringMultiMapEqualRange(sit->second, key); + const auto range = sit->second.equal_range(key); for (auto iter = range.first; iter != range.second; ++iter) ret.emplace_back(iter->second); } @@ -226,11 +226,11 @@ std::vector MemorySettingsInterface::GetStringList(const char* sect void MemorySettingsInterface::SetStringList(const char* section, const char* key, const std::vector& items) { - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); if (sit == m_sections.end()) sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first; - const auto range = UnorderedStringMultiMapEqualRange(sit->second, key); + const auto range = sit->second.equal_range(key); for (auto iter = range.first; iter != range.second;) sit->second.erase(iter++); @@ -241,11 +241,11 @@ void MemorySettingsInterface::SetStringList(const char* section, const char* key bool MemorySettingsInterface::RemoveFromStringList(const char* section, const char* key, const char* item) { - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); if (sit == m_sections.end()) sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first; - const auto range = UnorderedStringMultiMapEqualRange(sit->second, key); + const auto range = sit->second.equal_range(key); bool result = false; for (auto iter = range.first; iter != range.second;) { @@ -265,11 +265,11 @@ bool MemorySettingsInterface::RemoveFromStringList(const char* section, const ch bool MemorySettingsInterface::AddToStringList(const char* section, const char* key, const char* item) { - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); if (sit == m_sections.end()) sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first; - const auto range = UnorderedStringMultiMapEqualRange(sit->second, key); + const auto range = sit->second.equal_range(key); for (auto iter = range.first; iter != range.second; ++iter) { if (iter->second == item) @@ -282,7 +282,7 @@ bool MemorySettingsInterface::AddToStringList(const char* section, const char* k bool MemorySettingsInterface::ContainsValue(const char* section, const char* key) const { - const auto sit = UnorderedStringMapFind(m_sections, section); + const auto sit = m_sections.find(section); if (sit == m_sections.end()) return false; @@ -291,18 +291,18 @@ bool MemorySettingsInterface::ContainsValue(const char* section, const char* key void MemorySettingsInterface::DeleteValue(const char* section, const char* key) { - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); if (sit == m_sections.end()) return; - const auto range = UnorderedStringMultiMapEqualRange(sit->second, key); + const auto range = sit->second.equal_range(key); for (auto iter = range.first; iter != range.second;) sit->second.erase(iter++); } void MemorySettingsInterface::ClearSection(const char* section) { - auto sit = UnorderedStringMapFind(m_sections, section); + auto sit = m_sections.find(section); if (sit == m_sections.end()) return; diff --git a/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp b/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp index 0e45d7ce6c..7124b1604c 100644 --- a/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp +++ b/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp @@ -192,7 +192,7 @@ QTreeWidgetItem* GameCheatSettingsWidget::getTreeWidgetParent(const std::string_ if (parent.empty()) return nullptr; - auto it = UnorderedStringMapFind(m_parent_map, parent); + auto it = m_parent_map.find(parent); if (it != m_parent_map.end()) return it->second; diff --git a/pcsx2/GameList.cpp b/pcsx2/GameList.cpp index f2f16b7940..5d09c8e0a5 100644 --- a/pcsx2/GameList.cpp +++ b/pcsx2/GameList.cpp @@ -353,7 +353,7 @@ bool GameList::PopulateEntryFromPath(const std::string& path, GameList::Entry* e bool GameList::GetGameListEntryFromCache(const std::string& path, GameList::Entry* entry) { - auto iter = UnorderedStringMapFind(s_cache_map, path); + auto iter = s_cache_map.find(path); if (iter == s_cache_map.end()) return false; @@ -449,7 +449,7 @@ bool GameList::LoadEntriesFromCache(std::FILE* stream) ge.compatibility_rating = static_cast(compatibility_rating); ge.last_modified_time = static_cast(last_modified_time); - auto iter = UnorderedStringMapFind(s_cache_map, ge.path); + auto iter = s_cache_map.find(ge.path); if (iter != s_cache_map.end()) iter->second = std::move(ge); else @@ -637,7 +637,7 @@ bool GameList::AddFileFromCache(const std::string& path, std::time_t timestamp, if (entry.type == EntryType::Invalid) return true; - auto iter = UnorderedStringMapFind(played_time_map, entry.serial); + auto iter = played_time_map.find(entry.serial); if (iter != played_time_map.end()) { entry.last_played_time = iter->second.last_played_time; @@ -675,7 +675,7 @@ bool GameList::ScanFile( return true; } - auto iter = UnorderedStringMapFind(played_time_map, entry.serial); + auto iter = played_time_map.find(entry.serial); if (iter != played_time_map.end()) { entry.last_played_time = iter->second.last_played_time; @@ -912,7 +912,7 @@ GameList::PlayedTimeMap GameList::LoadPlayedTimeMap(const std::string& path) if (!ParsePlayedTimeLine(line, serial, entry)) continue; - if (UnorderedStringMapFind(ret, serial) != ret.end()) + if (ret.find(serial) != ret.end()) { Console.Warning("(LoadPlayedTimeMap) Duplicate entry: '%s'", serial.c_str()); continue; diff --git a/pcsx2/Host.cpp b/pcsx2/Host.cpp index bde19075fa..fdc6c7f8f0 100644 --- a/pcsx2/Host.cpp +++ b/pcsx2/Host.cpp @@ -68,12 +68,12 @@ std::pair Host::LookupTranslationString(const std::string_view } s_translation_string_mutex.lock_shared(); - ctx_it = UnorderedStringMapFind(s_translation_string_map, context); + ctx_it = s_translation_string_map.find(context); if (unlikely(ctx_it == s_translation_string_map.end())) goto add_string; - msg_it = UnorderedStringMapFind(ctx_it->second, msg); + msg_it = ctx_it->second.find(msg); if (unlikely(msg_it == ctx_it->second.end())) goto add_string;