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

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 08:42:11 PST 2025


================
@@ -1105,6 +1078,18 @@ class SmallDenseMap
                     static_cast<unsigned>(NextPowerOf2(MinNumBuckets - 1)));
   }
 
+  bool maybeSwapFast(SmallDenseMap &Other) {
+    if (Small || Other.Small)
+      return false;
+
+    unsigned Tmp = Other.NumEntries;
+    Other.NumEntries = NumEntries;
+    NumEntries = Tmp;
----------------
kazutakahirata wrote:

No, we cannot use `std::swap` on a bitfield.

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


More information about the llvm-commits mailing list