Skip to content

Commit 0359677

Browse files
[Driver] Avoid repeated hash lookups (NFC) (#130888)
1 parent e5aac52 commit 0359677

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,17 +1090,14 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
10901090
std::string NormalizedName = TT.normalize();
10911091

10921092
// Make sure we don't have a duplicate triple.
1093-
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
1094-
if (Duplicate != FoundNormalizedTriples.end()) {
1093+
auto [TripleIt, Inserted] =
1094+
FoundNormalizedTriples.try_emplace(NormalizedName, Val);
1095+
if (!Inserted) {
10951096
Diag(clang::diag::warn_drv_omp_offload_target_duplicate)
1096-
<< Val << Duplicate->second;
1097+
<< Val << TripleIt->second;
10971098
continue;
10981099
}
10991100

1100-
// Store the current triple so that we can check for duplicates in the
1101-
// following iterations.
1102-
FoundNormalizedTriples[NormalizedName] = Val;
1103-
11041101
// If the specified target is invalid, emit a diagnostic.
11051102
if (TT.getArch() == llvm::Triple::UnknownArch) {
11061103
Diag(clang::diag::err_drv_invalid_omp_target) << Val;

0 commit comments

Comments
 (0)