From 633ab2dd7c42d2e3d35740b885b60fb3c18569ed Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 20 Sep 2020 19:11:20 +0200 Subject: [PATCH] Store pointers in Config::SYSCONF_SETTINGS Not strictly necessary, but it reduces memory usage a little, and the next commit will make copying an Info object slower. --- Source/Core/Core/BootManager.cpp | 6 ++--- Source/Core/Core/Config/SYSCONFSettings.cpp | 22 +++++++++---------- Source/Core/Core/Config/SYSCONFSettings.h | 2 +- .../Core/ConfigLoaders/BaseConfigLoader.cpp | 20 ++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index a9f18b7ac8..a339ee80dd 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -472,11 +472,11 @@ static void RestoreSYSCONF() for (const auto& setting : Config::SYSCONF_SETTINGS) { std::visit( - [&](auto& info) { + [&](auto* info) { // If this setting was overridden, then we copy the base layer value back to the SYSCONF. // Otherwise we leave the new value in the SYSCONF. - if (Config::GetActiveLayerForConfig(info) == Config::LayerType::Base) - Config::SetBase(info, temp_layer.Get(info)); + if (Config::GetActiveLayerForConfig(*info) == Config::LayerType::Base) + Config::SetBase(*info, temp_layer.Get(*info)); }, setting.config_info); } diff --git a/Source/Core/Core/Config/SYSCONFSettings.cpp b/Source/Core/Core/Config/SYSCONFSettings.cpp index c2693a8d2b..3aaebc52bc 100644 --- a/Source/Core/Core/Config/SYSCONFSettings.cpp +++ b/Source/Core/Core/Config/SYSCONFSettings.cpp @@ -24,15 +24,15 @@ const Info SYSCONF_SPEAKER_VOLUME{{System::SYSCONF, "BT", "SPKV"}, 0x58}; const Info SYSCONF_WIIMOTE_MOTOR{{System::SYSCONF, "BT", "MOT"}, true}; const std::array SYSCONF_SETTINGS{ - {{SYSCONF_SCREENSAVER, SysConf::Entry::Type::Byte}, - {SYSCONF_LANGUAGE, SysConf::Entry::Type::Byte}, - {SYSCONF_COUNTRY, SysConf::Entry::Type::BigArray}, - {SYSCONF_WIDESCREEN, SysConf::Entry::Type::Byte}, - {SYSCONF_PROGRESSIVE_SCAN, SysConf::Entry::Type::Byte}, - {SYSCONF_PAL60, SysConf::Entry::Type::Byte}, - {SYSCONF_SOUND_MODE, SysConf::Entry::Type::Byte}, - {SYSCONF_SENSOR_BAR_POSITION, SysConf::Entry::Type::Byte}, - {SYSCONF_SENSOR_BAR_SENSITIVITY, SysConf::Entry::Type::Long}, - {SYSCONF_SPEAKER_VOLUME, SysConf::Entry::Type::Byte}, - {SYSCONF_WIIMOTE_MOTOR, SysConf::Entry::Type::Byte}}}; + {{&SYSCONF_SCREENSAVER, SysConf::Entry::Type::Byte}, + {&SYSCONF_LANGUAGE, SysConf::Entry::Type::Byte}, + {&SYSCONF_COUNTRY, SysConf::Entry::Type::BigArray}, + {&SYSCONF_WIDESCREEN, SysConf::Entry::Type::Byte}, + {&SYSCONF_PROGRESSIVE_SCAN, SysConf::Entry::Type::Byte}, + {&SYSCONF_PAL60, SysConf::Entry::Type::Byte}, + {&SYSCONF_SOUND_MODE, SysConf::Entry::Type::Byte}, + {&SYSCONF_SENSOR_BAR_POSITION, SysConf::Entry::Type::Byte}, + {&SYSCONF_SENSOR_BAR_SENSITIVITY, SysConf::Entry::Type::Long}, + {&SYSCONF_SPEAKER_VOLUME, SysConf::Entry::Type::Byte}, + {&SYSCONF_WIIMOTE_MOTOR, SysConf::Entry::Type::Byte}}}; } // namespace Config diff --git a/Source/Core/Core/Config/SYSCONFSettings.h b/Source/Core/Core/Config/SYSCONFSettings.h index 08efeb589e..e0f91b148c 100644 --- a/Source/Core/Core/Config/SYSCONFSettings.h +++ b/Source/Core/Core/Config/SYSCONFSettings.h @@ -33,7 +33,7 @@ extern const Info SYSCONF_WIIMOTE_MOTOR; struct SYSCONFSetting { - std::variant, Info> config_info; + std::variant*, const Info*> config_info; SysConf::Entry::Type type; }; diff --git a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp index 6598561e32..f54e2ac9f5 100644 --- a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp @@ -40,16 +40,16 @@ void SaveToSYSCONF(Config::LayerType layer) for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS) { std::visit( - [layer, &setting, &sysconf](auto& info) { - const std::string key = info.GetLocation().section + "." + info.GetLocation().key; + [layer, &setting, &sysconf](auto* info) { + const std::string key = info->GetLocation().section + "." + info->GetLocation().key; if (setting.type == SysConf::Entry::Type::Long) { - sysconf.SetData(key, setting.type, Config::Get(layer, info)); + sysconf.SetData(key, setting.type, Config::Get(layer, *info)); } else if (setting.type == SysConf::Entry::Type::Byte) { - sysconf.SetData(key, setting.type, static_cast(Config::Get(layer, info))); + sysconf.SetData(key, setting.type, static_cast(Config::Get(layer, *info))); } else if (setting.type == SysConf::Entry::Type::BigArray) { @@ -58,7 +58,7 @@ void SaveToSYSCONF(Config::LayerType layer) SysConf::Entry* entry = sysconf.GetOrAddEntry(key, setting.type); if (entry->bytes.size() < 0x1007 + 1) entry->bytes.resize(0x1007 + 1); - *reinterpret_cast(entry->bytes.data()) = Config::Get(layer, info); + *reinterpret_cast(entry->bytes.data()) = Config::Get(layer, *info); } }, setting.config_info); @@ -179,22 +179,22 @@ private: for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS) { std::visit( - [&](auto& info) { - const Config::Location location = info.GetLocation(); + [&](auto* info) { + const Config::Location location = info->GetLocation(); const std::string key = location.section + "." + location.key; if (setting.type == SysConf::Entry::Type::Long) { - layer->Set(location, sysconf.GetData(key, info.GetDefaultValue())); + layer->Set(location, sysconf.GetData(key, info->GetDefaultValue())); } else if (setting.type == SysConf::Entry::Type::Byte) { - layer->Set(location, sysconf.GetData(key, info.GetDefaultValue())); + layer->Set(location, sysconf.GetData(key, info->GetDefaultValue())); } else if (setting.type == SysConf::Entry::Type::BigArray) { // Somewhat hacky support for IPL.SADR. The setting only stores the // first 4 bytes even thought the SYSCONF entry is much bigger. - u32 value = info.GetDefaultValue(); + u32 value = info->GetDefaultValue(); SysConf::Entry* entry = sysconf.GetEntry(key); if (entry) {