mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-07 05:29:13 -06:00
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:
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user