[clang-tools-extra] 78768c5 - [clang-move] Avoid repeated hash lookups (NFC) (#109374)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 07:57:52 PDT 2024


Author: Kazu Hirata
Date: 2024-09-20T07:57:49-07:00
New Revision: 78768c52a0e5d9915ee75a190b07114c174ff8cb

URL: https://github.com/llvm/llvm-project/commit/78768c52a0e5d9915ee75a190b07114c174ff8cb
DIFF: https://github.com/llvm/llvm-project/commit/78768c52a0e5d9915ee75a190b07114c174ff8cb.diff

LOG: [clang-move] Avoid repeated hash lookups (NFC) (#109374)

Added: 
    

Modified: 
    clang-tools-extra/clang-move/HelperDeclRefGraph.cpp

Removed: 
    


################################################################################
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