mirror of https://github.com/PCSX2/pcsx2.git
Misc: Remove string map lookup wrappers
No longer needed.
This commit is contained in:
parent
4b50d016b5
commit
d2a5cdcca7
|
@ -71,43 +71,6 @@ using UnorderedStringSet =
|
||||||
using UnorderedStringMultiSet =
|
using UnorderedStringMultiSet =
|
||||||
std::unordered_multiset<std::string, detail::transparent_string_hash, detail::transparent_string_equal>;
|
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>
|
template <typename ValueType>
|
||||||
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
|
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
|
|
|
@ -32,7 +32,7 @@ void MemorySettingsInterface::Clear()
|
||||||
|
|
||||||
bool MemorySettingsInterface::GetIntValue(const char* section, const char* key, s32* value) const
|
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())
|
if (sit == m_sections.end())
|
||||||
return false;
|
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
|
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())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
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
|
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())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
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
|
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())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
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
|
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())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
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
|
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())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
const auto iter = sit->second.find(key);
|
||||||
if (iter == sit->second.end())
|
if (iter == sit->second.end())
|
||||||
return false;
|
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>> MemorySettingsInterface::GetKeyValueList(const char* section) const
|
||||||
{
|
{
|
||||||
std::vector<std::pair<std::string, std::string>> output;
|
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())
|
if (sit != m_sections.end())
|
||||||
{
|
{
|
||||||
for (const auto& it : sit->second)
|
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)
|
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();
|
sit->second.clear();
|
||||||
for (const auto& [key, value] : items)
|
for (const auto& [key, value] : items)
|
||||||
sit->second.emplace(key, value);
|
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)
|
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())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
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())
|
if (range.first == sit->second.end())
|
||||||
{
|
{
|
||||||
sit->second.emplace(std::string(key), std::move(value));
|
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;
|
std::vector<std::string> ret;
|
||||||
|
|
||||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
const auto sit = m_sections.find(section);
|
||||||
if (sit != m_sections.end())
|
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)
|
for (auto iter = range.first; iter != range.second; ++iter)
|
||||||
ret.emplace_back(iter->second);
|
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)
|
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())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
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;)
|
for (auto iter = range.first; iter != range.second;)
|
||||||
sit->second.erase(iter++);
|
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)
|
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())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
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;
|
bool result = false;
|
||||||
for (auto iter = range.first; iter != range.second;)
|
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)
|
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())
|
if (sit == m_sections.end())
|
||||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
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)
|
for (auto iter = range.first; iter != range.second; ++iter)
|
||||||
{
|
{
|
||||||
if (iter->second == item)
|
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
|
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())
|
if (sit == m_sections.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -291,18 +291,18 @@ bool MemorySettingsInterface::ContainsValue(const char* section, const char* key
|
||||||
|
|
||||||
void MemorySettingsInterface::DeleteValue(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())
|
if (sit == m_sections.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
const auto range = sit->second.equal_range(key);
|
||||||
for (auto iter = range.first; iter != range.second;)
|
for (auto iter = range.first; iter != range.second;)
|
||||||
sit->second.erase(iter++);
|
sit->second.erase(iter++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemorySettingsInterface::ClearSection(const char* section)
|
void MemorySettingsInterface::ClearSection(const char* section)
|
||||||
{
|
{
|
||||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
auto sit = m_sections.find(section);
|
||||||
if (sit == m_sections.end())
|
if (sit == m_sections.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ QTreeWidgetItem* GameCheatSettingsWidget::getTreeWidgetParent(const std::string_
|
||||||
if (parent.empty())
|
if (parent.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto it = UnorderedStringMapFind(m_parent_map, parent);
|
auto it = m_parent_map.find(parent);
|
||||||
if (it != m_parent_map.end())
|
if (it != m_parent_map.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ bool GameList::PopulateEntryFromPath(const std::string& path, GameList::Entry* e
|
||||||
|
|
||||||
bool GameList::GetGameListEntryFromCache(const std::string& path, GameList::Entry* entry)
|
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())
|
if (iter == s_cache_map.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ bool GameList::LoadEntriesFromCache(std::FILE* stream)
|
||||||
ge.compatibility_rating = static_cast<CompatibilityRating>(compatibility_rating);
|
ge.compatibility_rating = static_cast<CompatibilityRating>(compatibility_rating);
|
||||||
ge.last_modified_time = static_cast<std::time_t>(last_modified_time);
|
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())
|
if (iter != s_cache_map.end())
|
||||||
iter->second = std::move(ge);
|
iter->second = std::move(ge);
|
||||||
else
|
else
|
||||||
|
@ -637,7 +637,7 @@ bool GameList::AddFileFromCache(const std::string& path, std::time_t timestamp,
|
||||||
if (entry.type == EntryType::Invalid)
|
if (entry.type == EntryType::Invalid)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
auto iter = UnorderedStringMapFind(played_time_map, entry.serial);
|
auto iter = played_time_map.find(entry.serial);
|
||||||
if (iter != played_time_map.end())
|
if (iter != played_time_map.end())
|
||||||
{
|
{
|
||||||
entry.last_played_time = iter->second.last_played_time;
|
entry.last_played_time = iter->second.last_played_time;
|
||||||
|
@ -675,7 +675,7 @@ bool GameList::ScanFile(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iter = UnorderedStringMapFind(played_time_map, entry.serial);
|
auto iter = played_time_map.find(entry.serial);
|
||||||
if (iter != played_time_map.end())
|
if (iter != played_time_map.end())
|
||||||
{
|
{
|
||||||
entry.last_played_time = iter->second.last_played_time;
|
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))
|
if (!ParsePlayedTimeLine(line, serial, entry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (UnorderedStringMapFind(ret, serial) != ret.end())
|
if (ret.find(serial) != ret.end())
|
||||||
{
|
{
|
||||||
Console.Warning("(LoadPlayedTimeMap) Duplicate entry: '%s'", serial.c_str());
|
Console.Warning("(LoadPlayedTimeMap) Duplicate entry: '%s'", serial.c_str());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -68,12 +68,12 @@ std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view
|
||||||
}
|
}
|
||||||
|
|
||||||
s_translation_string_mutex.lock_shared();
|
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()))
|
if (unlikely(ctx_it == s_translation_string_map.end()))
|
||||||
goto add_string;
|
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()))
|
if (unlikely(msg_it == ctx_it->second.end()))
|
||||||
goto add_string;
|
goto add_string;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue