[clang] [Driver] Avoid repeated hash lookups (NFC) (PR #108676)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 13 20:24:11 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/108676

None

>From b35263dc9e52ded55eed57c03dc34b13f56ec6eb Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 13 Sep 2024 09:51:04 -0700
Subject: [PATCH] [Driver] Avoid repeated hash lookups (NFC)

---
 clang/lib/Driver/OffloadBundler.cpp | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp
index a4ab846ed2c57a..aaa4fdf03be1eb 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -1760,16 +1760,8 @@ Error OffloadBundler::UnbundleArchive() {
 
           // For inserting <CompatibleTarget, list<CodeObject>> entry in
           // OutputArchivesMap.
-          if (!OutputArchivesMap.contains(CompatibleTarget)) {
-
-            std::vector<NewArchiveMember> ArchiveMembers;
-            ArchiveMembers.push_back(NewArchiveMember(MemBufRef));
-            OutputArchivesMap.insert_or_assign(CompatibleTarget,
-                                               std::move(ArchiveMembers));
-          } else {
-            OutputArchivesMap[CompatibleTarget].push_back(
-                NewArchiveMember(MemBufRef));
-          }
+          OutputArchivesMap[CompatibleTarget].push_back(
+              NewArchiveMember(MemBufRef));
         }
       }
 



More information about the cfe-commits mailing list