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.
This commit is contained in:
Sintendo
2025-07-06 08:41:12 +02:00
parent a5e85caf0a
commit f2392e4048
15 changed files with 69 additions and 74 deletions

View File

@ -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)