[clang-tools-extra] [clang-change-namespace] Avoid repeated hash lookups (NFC) (PR #111784)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 9 20:11:55 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/111784.diff


1 Files Affected:

- (modified) clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp (+1-2) 


``````````diff
diff --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index 879c0d26d472a8..850df7daf5c038 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -606,9 +606,8 @@ void ChangeNamespaceTool::run(
                  Result.Nodes.getNodeAs<DeclRefExpr>("func_ref")) {
     // If this reference has been processed as a function call, we do not
     // process it again.
-    if (ProcessedFuncRefs.count(FuncRef))
+    if (!ProcessedFuncRefs.insert(FuncRef).second)
       return;
-    ProcessedFuncRefs.insert(FuncRef);
     const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("func_decl");
     assert(Func);
     const auto *Context = Result.Nodes.getNodeAs<Decl>("dc");

``````````

</details>


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


More information about the cfe-commits mailing list