Skip to content

Commit 571354e

Browse files
[clang-tidy] Avoid repeated hash lookups (NFC) (#112074)
1 parent b192f20 commit 571354e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ static bool mayShadow(const NamedDecl *ND0,
137137
const ConfusableIdentifierCheck::ContextInfo *
138138
ConfusableIdentifierCheck::getContextInfo(const DeclContext *DC) {
139139
const DeclContext *PrimaryContext = DC->getPrimaryContext();
140-
auto It = ContextInfos.find(PrimaryContext);
141-
if (It != ContextInfos.end())
140+
auto [It, Inserted] = ContextInfos.try_emplace(PrimaryContext);
141+
if (!Inserted)
142142
return &It->second;
143143

144-
ContextInfo &Info = ContextInfos[PrimaryContext];
144+
ContextInfo &Info = It->second;
145145
Info.PrimaryContext = PrimaryContext;
146146
Info.NonTransparentContext = PrimaryContext;
147147

0 commit comments

Comments
 (0)