[llvm] 448d0ec - [Support] Use std::map::try_emplace (NFC) (#141374)

via llvm-commits llvm-commits at lists.llvm.org
Sat May 24 14:47:59 PDT 2025


Author: Kazu Hirata
Date: 2025-05-24T14:47:56-07:00
New Revision: 448d0ec82142e118c3e1b03d73e885b3e6e3db0e

URL: https://github.com/llvm/llvm-project/commit/448d0ec82142e118c3e1b03d73e885b3e6e3db0e
DIFF: https://github.com/llvm/llvm-project/commit/448d0ec82142e118c3e1b03d73e885b3e6e3db0e.diff

LOG: [Support] Use std::map::try_emplace (NFC) (#141374)

try_emplace can default-construct values, so we do not need to do so
on our own.

Added: 
    

Modified: 
    llvm/lib/Support/DAGDeltaAlgorithm.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/DAGDeltaAlgorithm.cpp b/llvm/lib/Support/DAGDeltaAlgorithm.cpp
index 48302b8cb0621..981536473d124 100644
--- a/llvm/lib/Support/DAGDeltaAlgorithm.cpp
+++ b/llvm/lib/Support/DAGDeltaAlgorithm.cpp
@@ -179,8 +179,8 @@ DAGDeltaAlgorithmImpl::DAGDeltaAlgorithmImpl(
     const std::vector<edge_ty> &Dependencies)
     : DDA(DDA) {
   for (change_ty Change : Changes) {
-    Predecessors.insert(std::make_pair(Change, std::vector<change_ty>()));
-    Successors.insert(std::make_pair(Change, std::vector<change_ty>()));
+    Predecessors.try_emplace(Change);
+    Successors.try_emplace(Change);
   }
   for (const edge_ty &Dep : Dependencies) {
     Predecessors[Dep.second].push_back(Dep.first);
@@ -210,7 +210,7 @@ DAGDeltaAlgorithmImpl::DAGDeltaAlgorithmImpl(
 
   // Invert to form the predecessor closure map.
   for (change_ty Change : Changes)
-    PredClosure.insert(std::make_pair(Change, std::set<change_ty>()));
+    PredClosure.try_emplace(Change);
   for (change_ty Change : Changes)
     for (succ_closure_iterator_ty it2 = succ_closure_begin(Change),
                                   ie2 = succ_closure_end(Change);


        


More information about the llvm-commits mailing list