[llvm] [ADT] Move the core logic of swapping to DenseMapBase::swap (NFC) (PR #168486)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 03:24:51 PST 2025


================
@@ -363,7 +363,16 @@ class DenseMapBase : public DebugEpochBase {
   void swap(DerivedT &RHS) {
     this->incrementEpoch();
     RHS.incrementEpoch();
-    derived().swapImpl(RHS);
+    if (derived().maybeSwapFast(RHS.derived()))
+      return;
+
+    DerivedT &LHS = derived();
+    DerivedT Tmp;
+    Tmp.destroyAll();
----------------
s-barannikov wrote:

Why do you call `destroyAll` on an object just created?

https://github.com/llvm/llvm-project/pull/168486


More information about the llvm-commits mailing list