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

@ -652,8 +652,8 @@ void TextureCacheBase::DoSaveState(PointerWrap& p)
auto refpair1 = std::make_pair(*id1, *id2);
auto refpair2 = std::make_pair(*id2, *id1);
if (!reference_pairs.contains(refpair1) && !reference_pairs.contains(refpair2))
reference_pairs.insert(refpair1);
if (!reference_pairs.contains(refpair2))
reference_pairs.insert(std::move(refpair1));
}
}