[llvm] [Support] Avoid repeated hash lookups (NFC) (PR #130891)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 11 21:27:37 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/lib/Support/DebugCounter.cpp (+4-3) 


``````````diff
diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp
index a5d8a704bdd21..3a5983c4788a1 100644
--- a/llvm/lib/Support/DebugCounter.cpp
+++ b/llvm/lib/Support/DebugCounter.cpp
@@ -208,9 +208,10 @@ void DebugCounter::print(raw_ostream &OS) const {
   OS << "Counters and values:\n";
   for (auto &CounterName : CounterNames) {
     unsigned CounterID = getCounterId(std::string(CounterName));
-    OS << left_justify(RegisteredCounters[CounterID], 32) << ": {"
-       << Us.Counters[CounterID].Count << ",";
-    printChunks(OS, Us.Counters[CounterID].Chunks);
+    auto &C = Us.Counters[CounterID];
+    OS << left_justify(RegisteredCounters[CounterID], 32) << ": {" << C.Count
+       << ",";
+    printChunks(OS, C.Chunks);
     OS << "}\n";
   }
 }

``````````

</details>


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


More information about the llvm-commits mailing list