https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/130888
None >From c765f16d8f2ddf5b5a4e833d6f1409635ab879c3 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Tue, 11 Mar 2025 16:16:48 -0700 Subject: [PATCH] [Driver] Avoid repeated hash lookups (NFC) --- clang/lib/Driver/Driver.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9457a19255f21..ba0a7c2180867 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1090,17 +1090,14 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, std::string NormalizedName = TT.normalize(); // Make sure we don't have a duplicate triple. - auto Duplicate = FoundNormalizedTriples.find(NormalizedName); - if (Duplicate != FoundNormalizedTriples.end()) { + auto [TripleIt, Inserted] = + FoundNormalizedTriples.try_emplace(NormalizedName, Val); + if (!Inserted) { Diag(clang::diag::warn_drv_omp_offload_target_duplicate) - << Val << Duplicate->second; + << Val << TripleIt->second; continue; } - // Store the current triple so that we can check for duplicates in the - // following iterations. - FoundNormalizedTriples[NormalizedName] = Val; - // If the specified target is invalid, emit a diagnostic. if (TT.getArch() == llvm::Triple::UnknownArch) { Diag(clang::diag::err_drv_invalid_omp_target) << Val; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits