https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/131064
None >From ce858bc0761b0cd7410ccb0858a4bc692933dbd5 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Wed, 12 Mar 2025 08:52:05 -0700 Subject: [PATCH] [AST] Avoid repeated hash lookups (NFC) --- clang/lib/AST/ASTImporter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 82180486f3c7c..0d9b5afc4e4a6 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -10527,12 +10527,11 @@ void ASTImporter::CompleteDecl (Decl *D) { } Decl *ASTImporter::MapImported(Decl *From, Decl *To) { - llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From); - assert((Pos == ImportedDecls.end() || Pos->second == To) && - "Try to import an already imported Decl"); - if (Pos != ImportedDecls.end()) + auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To); + assert((Inserted || Pos->second == To) && + "Try to import an already imported Decl"); + if (!Inserted) return Pos->second; - ImportedDecls[From] = To; // This mapping should be maintained only in this function. Therefore do not // check for additional consistency. ImportedFromDecls[To] = From; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits