[llvm] [ADT] Avoid repeated hash lookups (NFC) (PR #129355)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 28 20:11:37 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/include/llvm/ADT/SCCIterator.h (+3-3) 


``````````diff
diff --git a/llvm/include/llvm/ADT/SCCIterator.h b/llvm/include/llvm/ADT/SCCIterator.h
index 3bd103c13f19f..fef8cdb748442 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -354,10 +354,10 @@ scc_member_iterator<GraphT, GT>::scc_member_iterator(
   // Walk through SortedEdges to initialize the queue, instead of using NodeInfoMap
   // to ensure an ordered deterministic push.
   for (auto *Edge : SortedEdges) {
-    if (!NodeInfoMap[Edge->Source].Visited &&
-        NodeInfoMap[Edge->Source].IncomingMSTEdges.empty()) {
+    auto &Info = NodeInfoMap[Edge->Source];
+    if (!Info.Visited && Info.IncomingMSTEdges.empty()) {
       Queue.push(Edge->Source);
-      NodeInfoMap[Edge->Source].Visited = true;
+      Info.Visited = true;
     }
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list