[clang-tools-extra] [clang-tidy] Avoid repeated hash lookups (NFC) (PR #109373)

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp (+1-2) 


``````````diff
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 5e2cc207560d33..fef086c5a99d86 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -116,9 +116,8 @@ void ExpandModularHeadersPPCallbacks::handleModuleFile(
   if (!MF)
     return;
   // Avoid processing a ModuleFile more than once.
-  if (VisitedModules.count(MF))
+  if (!VisitedModules.insert(MF).second)
     return;
-  VisitedModules.insert(MF);
 
   // Visit all the input files of this module and mark them to record their
   // contents later.

``````````

</details>


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


More information about the cfe-commits mailing list