mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-26 22:38:34 +00:00
Common: Optimize Config::Get
The way Config::Get works in master, it first calls Config::GetActiveLayerForConfig which searches for the setting in all layers, and then calls Config::Layer::Get which searches for the same setting again within the given layer. We can remove this second search by combining the logic of Config::GetActiveLayerForConfig and Config::Layer::Get into one function.
This commit is contained in:
parent
140daf5960
commit
2f264c6448
2 changed files with 26 additions and 1 deletions
|
@ -178,6 +178,25 @@ LayerType GetActiveLayerForConfig(const Location& config)
|
|||
return LayerType::Base;
|
||||
}
|
||||
|
||||
std::optional<std::string> GetAsString(const Location& config)
|
||||
{
|
||||
std::optional<std::string> result;
|
||||
ReadLock lock(s_layers_rw_lock);
|
||||
|
||||
for (auto layer : SEARCH_ORDER)
|
||||
{
|
||||
const auto it = s_layers.find(layer);
|
||||
if (it != s_layers.end())
|
||||
{
|
||||
result = it->second->Get<std::string>(config);
|
||||
if (result.has_value())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ConfigChangeCallbackGuard::ConfigChangeCallbackGuard()
|
||||
{
|
||||
++s_callback_guards;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue