[clang-tools-extra] [clang-tidy] Avoid repeated hash lookups (NFC) (PR #111628)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 21:09:36 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111628
None
>From 04ac47ef9952eaeb4e9d8ef7f7b96cb050865a3a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 8 Oct 2024 20:42:13 -0700
Subject: [PATCH] [clang-tidy] Avoid repeated hash lookups (NFC)
---
.../clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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;
More information about the cfe-commits
mailing list