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

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 19 22:09:36 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tools-extra

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) clang-tools-extra/clang-move/HelperDeclRefGraph.cpp (+1-2) 


``````````diff
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);
       };

``````````

</details>


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


More information about the cfe-commits mailing list