Skip to content

Conversation

kazutakahirata
Copy link
Contributor

This patch simplifies the swapping of *getLargeRep().

In other places, we treat the two member variables together like:

new (getLargeRep()) LargeRep(allocateBuckets(InitBuckets));

This patch makes the code a little more consistent with other places
copying/moving LargeRep.

This patch simplifies the swapping of *getLargeRep().

In other places, we treat the two member variables together like:

  new (getLargeRep()) LargeRep(allocateBuckets(InitBuckets));

This patch makes the code a little more consistent with other places
copying/moving LargeRep.
@llvmbot
Copy link
Member

llvmbot commented Aug 23, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

This patch simplifies the swapping of *getLargeRep().

In other places, we treat the two member variables together like:

new (getLargeRep()) LargeRep(allocateBuckets(InitBuckets));

This patch makes the code a little more consistent with other places
copying/moving LargeRep.


Full diff: https://github.com/llvm/llvm-project/pull/155067.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/DenseMap.h (+1-2)
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 2a35c3d583f70..156894aa7f0e3 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -1038,8 +1038,7 @@ class SmallDenseMap
       return;
     }
     if (!Small && !RHS.Small) {
-      std::swap(getLargeRep()->Buckets, RHS.getLargeRep()->Buckets);
-      std::swap(getLargeRep()->NumBuckets, RHS.getLargeRep()->NumBuckets);
+      std::swap(*getLargeRep(), *RHS.getLargeRep());
       return;
     }
 

@kazutakahirata kazutakahirata merged commit b147644 into llvm:main Aug 23, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250822_DenseMap_swap branch August 23, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants