[llvm] [ADT] Refactor DenseSet::insert (NFC) (PR #157324)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 6 23:59:21 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/157324
DenseMap::try_emplace can default-construct DenseSetEmptyKey, so we
don't need to pass Empty on our own.
>From 9be075aca65243158d6e9079174fc269071fd82d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 6 Sep 2025 18:36:33 -0700
Subject: [PATCH] [ADT] Refactor DenseSet::insert (NFC)
DenseMap::try_emplace can default-construct DenseSetEmptyKey, so we
don't need to pass Empty on our own.
---
llvm/include/llvm/ADT/DenseSet.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/ADT/DenseSet.h b/llvm/include/llvm/ADT/DenseSet.h
index 8ba74f6b9f746..281d4d1c78cc0 100644
--- a/llvm/include/llvm/ADT/DenseSet.h
+++ b/llvm/include/llvm/ADT/DenseSet.h
@@ -192,13 +192,11 @@ class DenseSetImpl {
void erase(const_iterator CI) { return TheMap.erase(CI.I); }
std::pair<iterator, bool> insert(const ValueT &V) {
- detail::DenseSetEmpty Empty;
- return TheMap.try_emplace(V, Empty);
+ return TheMap.try_emplace(V);
}
std::pair<iterator, bool> insert(ValueT &&V) {
- detail::DenseSetEmpty Empty;
- return TheMap.try_emplace(std::move(V), Empty);
+ return TheMap.try_emplace(std::move(V));
}
/// Alternative version of insert that uses a different (and possibly less
More information about the llvm-commits
mailing list