From f5fd183571af0eb688536dbc3175edcd8c7a1d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 31 Jul 2017 16:26:46 +0800 Subject: [PATCH] Config: Fix the loader Load() being called twice The Config::AddLoadLayer functions call Load on the layer explicitly, but Load is already called in the constructor, so they'd cause the loader's Load function to be called twice, which is potentially expensive considering we have to read an INI from the host filesystem. This commit removes the Config::AddLoadLayer functions because they don't appear to be necessary. --- Source/Core/Common/Config/Config.cpp | 11 ----------- Source/Core/Common/Config/Config.h | 2 -- Source/Core/Core/BootManager.cpp | 6 +++--- Source/Core/UICommon/UICommon.cpp | 2 +- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp index 285db95f28..dcdcf4ba8f 100644 --- a/Source/Core/Common/Config/Config.cpp +++ b/Source/Core/Common/Config/Config.cpp @@ -38,17 +38,6 @@ void AddLayer(std::unique_ptr loader) AddLayer(std::make_unique(std::move(loader))); } -void AddLoadLayer(std::unique_ptr layer) -{ - layer->Load(); - AddLayer(std::move(layer)); -} - -void AddLoadLayer(std::unique_ptr loader) -{ - AddLoadLayer(std::make_unique(std::move(loader))); -} - Layer* GetLayer(LayerType layer) { if (!LayerExists(layer)) diff --git a/Source/Core/Common/Config/Config.h b/Source/Core/Common/Config/Config.h index d839569ace..2fa15eb4a1 100644 --- a/Source/Core/Common/Config/Config.h +++ b/Source/Core/Common/Config/Config.h @@ -43,8 +43,6 @@ Section* GetOrCreateSection(System system, const std::string& section_name); Layers* GetLayers(); void AddLayer(std::unique_ptr layer); void AddLayer(std::unique_ptr loader); -void AddLoadLayer(std::unique_ptr layer); -void AddLoadLayer(std::unique_ptr loader); Layer* GetLayer(LayerType layer); void RemoveLayer(LayerType layer); bool LayerExists(LayerType layer); diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index cffa64bbb8..6cf09d3666 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -244,8 +244,8 @@ bool BootCore(std::unique_ptr boot) std::string game_id = SConfig::GetInstance().GetGameID(); u16 revision = SConfig::GetInstance().GetRevision(); - Config::AddLoadLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision)); - Config::AddLoadLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision)); + Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision)); + Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision)); IniFile game_ini = StartUp.LoadGameIni(); @@ -357,7 +357,7 @@ bool BootCore(std::unique_ptr boot) if (NetPlay::IsNetPlayRunning()) { - Config::AddLoadLayer(ConfigLoaders::GenerateNetPlayConfigLoader(g_NetPlaySettings)); + Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(g_NetPlaySettings)); StartUp.bCPUThread = g_NetPlaySettings.m_CPUthread; StartUp.bEnableCheats = g_NetPlaySettings.m_EnableCheats; StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE; diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index 691644edf5..507213f25d 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -33,7 +33,7 @@ namespace UICommon void Init() { Config::Init(); - Config::AddLoadLayer(ConfigLoaders::GenerateBaseConfigLoader()); + Config::AddLayer(ConfigLoaders::GenerateBaseConfigLoader()); SConfig::Init(); LogManager::Init(); VideoBackendBase::PopulateList();