Skip to content

Conversation

kazutakahirata
Copy link
Contributor

DenseMap::try_emplace can default-construct DenseSetEmptyKey, so we
don't need to pass Empty on our own.

DenseMap::try_emplace can default-construct DenseSetEmptyKey, so we
don't need to pass Empty on our own.
@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

DenseMap::try_emplace can default-construct DenseSetEmptyKey, so we
don't need to pass Empty on our own.


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

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/DenseSet.h (+2-4)
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

@kazutakahirata kazutakahirata merged commit 13647d8 into llvm:main Sep 7, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250906pm_ADT_DenseSet_insert_empty branch September 7, 2025 17:44
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.

4 participants