[llvm] [ADT] Simplify SmallDenseMap::swap (NFC) (PR #155067)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 22 20:54:31 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/155067
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.
>From 69640a62a45fd6b6f4b4b18dc345c7d1c6bdefb9 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 19 Aug 2025 09:22:31 -0700
Subject: [PATCH] [ADT] Simplify SmallDenseMap::swap (NFC)
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.
---
llvm/include/llvm/ADT/DenseMap.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
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;
}
More information about the llvm-commits
mailing list