[clang] [LifetimeSafety] Avoid adding already present items in sets/maps (PR #159582)
Jan Voung via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 19 05:29:32 PDT 2025
================
@@ -910,6 +910,8 @@ template <typename T>
static llvm::ImmutableSet<T> join(llvm::ImmutableSet<T> A,
llvm::ImmutableSet<T> B,
typename llvm::ImmutableSet<T>::Factory &F) {
+ if (A == B)
+ return A;
----------------
jvoung wrote:
would the `add()` on line 918 also possibly do more allocation than desired (and cost more than checking if contains first), if `E` was already in `A` ?
https://github.com/llvm/llvm-project/pull/159582
More information about the cfe-commits
mailing list