[llvm] 9a99e55 - [gold-plugin] Avoid repeated hash lookups (NFC) (#109748)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 16:39:51 PDT 2024


Author: Kazu Hirata
Date: 2024-09-24T16:39:47-07:00
New Revision: 9a99e559322e999240184f0159993023ffb355f1

URL: https://github.com/llvm/llvm-project/commit/9a99e559322e999240184f0159993023ffb355f1
DIFF: https://github.com/llvm/llvm-project/commit/9a99e559322e999240184f0159993023ffb355f1.diff

LOG: [gold-plugin] Avoid repeated hash lookups (NFC) (#109748)

Added: 
    

Modified: 
    llvm/tools/gold/gold-plugin.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index 0b175a3852e425..0377791d85b3f8 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -1057,9 +1057,11 @@ static std::vector<std::pair<SmallString<128>, bool>> runLTO() {
   getThinLTOOldAndNewSuffix(OldSuffix, NewSuffix);
 
   for (claimed_file &F : Modules) {
-    if (options::thinlto && !HandleToInputFile.count(F.leader_handle))
-      HandleToInputFile.insert(std::make_pair(
-          F.leader_handle, std::make_unique<PluginInputFile>(F.handle)));
+    if (options::thinlto) {
+      auto [It, Inserted] = HandleToInputFile.try_emplace(F.leader_handle);
+      if (Inserted)
+        It->second = std::make_unique<PluginInputFile>(F.handle);
+    }
     // In case we are thin linking with a minimized bitcode file, ensure
     // the module paths encoded in the index reflect where the backends
     // will locate the full bitcode files for compiling/importing.


        


More information about the llvm-commits mailing list