Misc: Remove string map lookup wrappers

No longer needed.
This commit is contained in:
Stenzek 2023-07-22 13:15:26 +10:00 committed by Connor McLaughlin
parent 4b50d016b5
commit d2a5cdcca7
5 changed files with 35 additions and 72 deletions

View File

@ -71,43 +71,6 @@ using UnorderedStringSet =
using UnorderedStringMultiSet =
std::unordered_multiset<std::string, detail::transparent_string_hash, detail::transparent_string_equal>;
template <typename KeyType, typename ValueType>
__fi typename UnorderedStringMap<ValueType>::const_iterator
UnorderedStringMapFind(const UnorderedStringMap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template <typename KeyType, typename ValueType>
__fi typename UnorderedStringMap<ValueType>::iterator
UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template <typename KeyType, typename ValueType>
__fi typename UnorderedStringMultimap<ValueType>::const_iterator
UnorderedStringMultiMapFind(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template <typename KeyType, typename ValueType>
__fi std::pair<typename UnorderedStringMultimap<ValueType>::const_iterator, typename UnorderedStringMultimap<ValueType>::const_iterator>
UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.equal_range(key);
}
template <typename KeyType, typename ValueType>
__fi typename UnorderedStringMultimap<ValueType>::iterator
UnorderedStringMultiMapFind(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template <typename KeyType, typename ValueType>
__fi std::pair<typename UnorderedStringMultimap<ValueType>::iterator, typename UnorderedStringMultimap<ValueType>::iterator>
UnorderedStringMultiMapEqualRange(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.equal_range(key);
}
template <typename ValueType>
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
template <typename ValueType>

View File

@ -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<std::pair<std::string, std::string>> MemorySettingsInterface::GetKeyValueList(const char* section) const
{
std::vector<std::pair<std::string, std::string>> 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<std::pair<std::string, std::string>> MemorySettingsInterface::GetKey
void MemorySettingsInterface::SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& 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<std::string> MemorySettingsInterface::GetStringList(const char* sect
{
std::vector<std::string> 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<std::string> MemorySettingsInterface::GetStringList(const char* sect
void MemorySettingsInterface::SetStringList(const char* section, const char* key, const std::vector<std::string>& 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;

View File

@ -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;

View File

@ -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<CompatibilityRating>(compatibility_rating);
ge.last_modified_time = static_cast<std::time_t>(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;

View File

@ -68,12 +68,12 @@ std::pair<const char*, u32> 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;