[clang] [clang-offload-bundler] Avoid repeated hash lookups (NFC) (PR #109507)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 20:40:47 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/109507.diff


1 Files Affected:

- (modified) clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp (+1-2) 


``````````diff
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();

``````````

</details>


https://github.com/llvm/llvm-project/pull/109507


More information about the cfe-commits mailing list