[clang-tools-extra] [clang-move] Avoid repeated hash lookups (NFC) (PR #109374)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 19 22:09:02 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/109374
None
>From 5e05b5835a639eb211a381b03057b8ff9f7be6df Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 19 Sep 2024 09:39:33 -0700
Subject: [PATCH] [clang-move] Avoid repeated hash lookups (NFC)
---
clang-tools-extra/clang-move/HelperDeclRefGraph.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/clang-tools-extra/clang-move/HelperDeclRefGraph.cpp b/clang-tools-extra/clang-move/HelperDeclRefGraph.cpp
index a9b773353fe696..ae7dc5b2c0548b 100644
--- a/clang-tools-extra/clang-move/HelperDeclRefGraph.cpp
+++ b/clang-tools-extra/clang-move/HelperDeclRefGraph.cpp
@@ -76,9 +76,8 @@ HelperDeclRefGraph::getReachableNodes(const Decl *Root) const {
llvm::DenseSet<const CallGraphNode *> ConnectedNodes;
std::function<void(const CallGraphNode *)> VisitNode =
[&](const CallGraphNode *Node) {
- if (ConnectedNodes.count(Node))
+ if (!ConnectedNodes.insert(Node).second)
return;
- ConnectedNodes.insert(Node);
for (auto It = Node->begin(), End = Node->end(); It != End; ++It)
VisitNode(*It);
};
More information about the cfe-commits
mailing list