[llvm] [ADT] Refactor DenseSet::insert (NFC) (PR #157324)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 6 23:59:53 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

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
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

``````````

</details>


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


More information about the llvm-commits mailing list