[clang] [clang-offload-bundler] Avoid repeated hash lookups (NFC) (PR #109507)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 20 20:40:14 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/109507
None
>From a08161a8308d724e7cf41ee0f603321ee6a121d4 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 20 Sep 2024 13:32:54 -0700
Subject: [PATCH] [clang-offload-bundler] Avoid repeated hash lookups (NFC)
---
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index e336417586f70b..0189fe5d56ab2a 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -349,11 +349,10 @@ int main(int argc, const char **argv) {
// Standardize target names to include env field
std::vector<std::string> StandardizedTargetNames;
for (StringRef Target : TargetNames) {
- if (ParsedTargets.contains(Target)) {
+ if (!ParsedTargets.insert(Target).second) {
reportError(createStringError(errc::invalid_argument,
"Duplicate targets are not allowed"));
}
- ParsedTargets.insert(Target);
auto OffloadInfo = OffloadTargetInfo(Target, BundlerConfig);
bool KindIsValid = OffloadInfo.isOffloadKindValid();
More information about the cfe-commits
mailing list