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

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 14 19:33:06 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/131418

None

>From 9ec1f1d22903e2c9500053e034cecab9a03390d3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 14 Mar 2025 07:24:49 -0700
Subject: [PATCH] [ADT] Avoid repeated hash lookups (NFC)

---
 llvm/include/llvm/ADT/SCCIterator.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/ADT/SCCIterator.h b/llvm/include/llvm/ADT/SCCIterator.h
index fef8cdb748442..64ee217eeed61 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -366,9 +366,9 @@ scc_member_iterator<GraphT, GT>::scc_member_iterator(
     Queue.pop();
     Nodes.push_back(Node);
     for (auto &Edge : Node->Edges) {
-      NodeInfoMap[Edge.Target].IncomingMSTEdges.erase(&Edge);
-      if (MSTEdges.count(&Edge) &&
-          NodeInfoMap[Edge.Target].IncomingMSTEdges.empty()) {
+      NodeInfo &Info = NodeInfoMap[Edge.Target];
+      Info.IncomingMSTEdges.erase(&Edge);
+      if (MSTEdges.count(&Edge) && Info.IncomingMSTEdges.empty()) {
         Queue.push(Edge.Target);
       }
     }



More information about the llvm-commits mailing list