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. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index f58460e9ad..dc47eac86e 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -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)); } } -- cgit v1.2.3