diff --git a/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp b/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp index 2151642d2b..f8f0bc86db 100644 --- a/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp +++ b/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp @@ -185,7 +185,7 @@ void GraphicsModListWidget::ModItemChanged(QListWidgetItem* item) m_needs_save = true; } -void GraphicsModListWidget::OnModChanged(std::optional absolute_path) +void GraphicsModListWidget::OnModChanged(const std::optional& absolute_path) { ClearLayoutRecursively(m_mod_meta_layout); @@ -198,7 +198,7 @@ void GraphicsModListWidget::OnModChanged(std::optional absolute_pat return; } - GraphicsModConfig* mod = m_mod_group.GetMod(*absolute_path); + const GraphicsModConfig* mod = m_mod_group.GetMod(*absolute_path); if (!mod) return; diff --git a/Source/Core/DolphinQt/Config/GraphicsModListWidget.h b/Source/Core/DolphinQt/Config/GraphicsModListWidget.h index 7b32792cff..ff310af56c 100644 --- a/Source/Core/DolphinQt/Config/GraphicsModListWidget.h +++ b/Source/Core/DolphinQt/Config/GraphicsModListWidget.h @@ -52,7 +52,7 @@ private: void ModSelectionChanged(); void ModItemChanged(QListWidgetItem* item); - void OnModChanged(std::optional absolute_path); + void OnModChanged(const std::optional& absolute_path); void SaveModList(); diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.cpp index 9ce417e079..0873c09e91 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include "Common/CommonPaths.h" #include "Common/FileSearch.h" #include "Common/FileUtil.h" @@ -83,7 +85,7 @@ void GraphicsModGroupConfig::Load() auto mod_full_path = graphics_mod->GetAbsolutePath(); known_paths.insert(std::move(mod_full_path)); - m_graphics_mods.push_back(*graphics_mod); + m_graphics_mods.push_back(std::move(*graphics_mod)); } } } @@ -93,15 +95,11 @@ void GraphicsModGroupConfig::Load() GraphicsModConfig::Source source) { auto file = dir + DIR_SEP + "metadata.json"; UnifyPathSeparators(file); - if (known_paths.find(file) != known_paths.end()) - { + if (known_paths.contains(file)) return; - } - const auto mod = GraphicsModConfig::Create(file, source); - if (mod) - { - m_graphics_mods.push_back(*mod); - } + + if (auto mod = GraphicsModConfig::Create(file, source)) + m_graphics_mods.push_back(std::move(*mod)); }; const std::set graphics_mod_user_directories = @@ -174,7 +172,7 @@ std::vector& GraphicsModGroupConfig::GetMods() return m_graphics_mods; } -GraphicsModConfig* GraphicsModGroupConfig::GetMod(const std::string& absolute_path) const +GraphicsModConfig* GraphicsModGroupConfig::GetMod(std::string_view absolute_path) const { if (const auto iter = m_path_to_graphics_mod.find(absolute_path); iter != m_path_to_graphics_mod.end()) diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h index 9614951e96..b2178db3f6 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h @@ -5,10 +5,9 @@ #include #include +#include #include -#include - #include "Common/CommonTypes.h" struct GraphicsModConfig; @@ -34,7 +33,7 @@ public: const std::vector& GetMods() const; std::vector& GetMods(); - GraphicsModConfig* GetMod(const std::string& absolute_path) const; + GraphicsModConfig* GetMod(std::string_view absolute_path) const; const std::string& GetGameID() const; @@ -42,6 +41,6 @@ private: std::string GetPath() const; std::string m_game_id; std::vector m_graphics_mods; - std::map m_path_to_graphics_mod; + std::map> m_path_to_graphics_mod; u32 m_change_count = 0; };