From f2392e4048ce977bad2227d08f3a042526f7c4da Mon Sep 17 00:00:00 2001 From: Sintendo <3380580+Sintendo@users.noreply.github.com> Date: Sun, 6 Jul 2025 08:41:12 +0200 Subject: Avoid map/set double lookups Fix some common anti-patterns with these data structures. - You can dereference the iterator returned by `find` to access the underlying value directly, without an extra `operator[]`/`at`. - Rather than checking for an element before insertion/deletion, you can just do the operation and if needed check the return value to determine if the insertion/deletion succeeded. --- .../Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/GraphicsModSystem') diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp index 0d070a4310..70d3a9a5ca 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp @@ -197,14 +197,13 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config) { for (const GraphicsTargetGroupConfig& group : mod.m_groups) { - if (m_groups.contains(group.m_name)) + if (const bool inserted = m_groups.insert(group.m_name).second; !inserted) { WARN_LOG_FMT( VIDEO, "Specified graphics mod group '{}' for mod '{}' is already specified by another mod.", group.m_name, mod.m_title); } - m_groups.insert(group.m_name); const auto internal_group = fmt::format("{}.{}", mod.m_title, group.m_name); for (const GraphicsTargetConfig& target : group.m_targets) -- cgit v1.2.3