Skip to content

Commit 670a461

Browse files
[clang-tidy] Avoid repeated hash lookups (NFC) (#111785)
1 parent d2a96d1 commit 670a461

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ void ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
146146
}
147147
// Check if a definition in another namespace exists.
148148
const auto DeclName = CurDecl->getName();
149-
if (!DeclNameToDefinitions.contains(DeclName)) {
149+
auto It = DeclNameToDefinitions.find(DeclName);
150+
if (It == DeclNameToDefinitions.end()) {
150151
continue; // No definition in this translation unit, we can skip it.
151152
}
152153
// Make a warning for each definition with the same name (in other
153154
// namespaces).
154-
const auto &Definitions = DeclNameToDefinitions[DeclName];
155+
const auto &Definitions = It->second;
155156
for (const auto *Def : Definitions) {
156157
diag(CurDecl->getLocation(),
157158
"no definition found for %0, but a definition with "

0 commit comments

Comments
 (0)