[clang-tools-extra] [clang-tidy] Avoid repeated hash lookups (NFC) (PR #111628)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 21:10:06 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/111628.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp (+1-3)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index 9c3c7cc70c187b..225e867c9b24f7 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -474,10 +474,8 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
// It only includes fields that have not been fixed
SmallPtrSet<const FieldDecl *, 16> AllFieldsToInit;
forEachField(ClassDecl, FieldsToInit, [&](const FieldDecl *F) {
- if (!HasRecordClassMemberSet.contains(F)) {
+ if (HasRecordClassMemberSet.insert(F).second)
AllFieldsToInit.insert(F);
- HasRecordClassMemberSet.insert(F);
- }
});
if (FieldsToInit.empty())
return;
``````````
</details>
https://github.com/llvm/llvm-project/pull/111628
More information about the cfe-commits
mailing list