[clang-tools-extra] 571354e - [clang-tidy] Avoid repeated hash lookups (NFC) (#112074)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 12 08:04:20 PDT 2024
Author: Kazu Hirata
Date: 2024-10-12T08:04:17-07:00
New Revision: 571354e25130b213146c26d05524fcd215fbd061
URL: https://github.com/llvm/llvm-project/commit/571354e25130b213146c26d05524fcd215fbd061
DIFF: https://github.com/llvm/llvm-project/commit/571354e25130b213146c26d05524fcd215fbd061.diff
LOG: [clang-tidy] Avoid repeated hash lookups (NFC) (#112074)
Added:
Modified:
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
index 5b1b1cd152fffb..6df565c9a9d691 100644
--- a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
@@ -137,11 +137,11 @@ static bool mayShadow(const NamedDecl *ND0,
const ConfusableIdentifierCheck::ContextInfo *
ConfusableIdentifierCheck::getContextInfo(const DeclContext *DC) {
const DeclContext *PrimaryContext = DC->getPrimaryContext();
- auto It = ContextInfos.find(PrimaryContext);
- if (It != ContextInfos.end())
+ auto [It, Inserted] = ContextInfos.try_emplace(PrimaryContext);
+ if (!Inserted)
return &It->second;
- ContextInfo &Info = ContextInfos[PrimaryContext];
+ ContextInfo &Info = It->second;
Info.PrimaryContext = PrimaryContext;
Info.NonTransparentContext = PrimaryContext;
More information about the cfe-commits
mailing list