Skip to content

Commit dec5589

Browse files
[AST] Avoid repeated hash lookups (NFC) (llvm#131064)
1 parent 8437b7f commit dec5589

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

clang/lib/AST/ASTImporter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10527,12 +10527,11 @@ void ASTImporter::CompleteDecl (Decl *D) {
1052710527
}
1052810528

1052910529
Decl *ASTImporter::MapImported(Decl *From, Decl *To) {
10530-
llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From);
10531-
assert((Pos == ImportedDecls.end() || Pos->second == To) &&
10532-
"Try to import an already imported Decl");
10533-
if (Pos != ImportedDecls.end())
10530+
auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To);
10531+
assert((Inserted || Pos->second == To) &&
10532+
"Try to import an already imported Decl");
10533+
if (!Inserted)
1053410534
return Pos->second;
10535-
ImportedDecls[From] = To;
1053610535
// This mapping should be maintained only in this function. Therefore do not
1053710536
// check for additional consistency.
1053810537
ImportedFromDecls[To] = From;

0 commit comments

Comments
 (0)