8000 [Support] Use std::map::try_emplace (NFC) by kazutakahirata · Pull Request #141374 · llvm/llvm-project · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8000 Merged

Conversation

kazutakahirata
Copy link
Contributor

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

try_emplace can default-construct values, so we do not need to do so
on our own.
@llvmbot
Copy link
Member
llvmbot commented May 24, 2025

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

Changes

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


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

1 Files Affected:

  • (modified) llvm/lib/Support/DAGDeltaAlgorithm.cpp (+3-3)
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);

@kazutakahirata kazutakahirata merged commit 448d0ec into llvm:main May 24, 2025
10 of 13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250524_try_emplace_llvm branch May 24, 2025 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0