[llvm] [DebugInfo] Simplify code with std::map::operator[] (NFC) (PR #115591)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 23:32:28 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/include/llvm/DebugInfo/GSYM/OutputAggregator.h (+2-5) 


``````````diff
diff --git a/llvm/include/llvm/DebugInfo/GSYM/OutputAggregator.h b/llvm/include/llvm/DebugInfo/GSYM/OutputAggregator.h
index 35ef0a8bc89085..ab20634b0b9384 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/OutputAggregator.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/OutputAggregator.h
@@ -60,11 +60,8 @@ class OutputAggregator {
   // then merge it in here. Note that this is *not* thread safe. It is up to
   // the caller to ensure that this is only called from one thread at a time.
   void Merge(const OutputAggregator &other) {
-    for (auto &&[name, count] : other.Aggregation) {
-      auto [it, inserted] = Aggregation.emplace(name, count);
-      if (!inserted)
-        it->second += count;
-    }
+    for (auto &&[name, count] : other.Aggregation)
+      Aggregation[name] += count;
   }
 };
 

``````````

</details>


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


More information about the llvm-commits mailing list