[llvm] 929d70a - [llvm-jitlink] Avoid repeated hash lookups (NFC) (#128399)

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 23 01:05:16 PST 2025


Author: Kazu Hirata
Date: 2025-02-23T01:05:13-08:00
New Revision: 929d70a38dadce82a48261d562784d53d286354f

URL: https://github.com/llvm/llvm-project/commit/929d70a38dadce82a48261d562784d53d286354f
DIFF: https://github.com/llvm/llvm-project/commit/929d70a38dadce82a48261d562784d53d286354f.diff

LOG: [llvm-jitlink] Avoid repeated hash lookups (NFC) (#128399)

Added: 
    

Modified: 
    llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
index 6db78926101fd..07d9406cacc52 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
@@ -69,14 +69,15 @@ Error registerCOFFGraphInfo(Session &S, LinkGraph &G) {
   std::lock_guard<std::mutex> Lock(S.M);
 
   auto FileName = sys::path::filename(G.getName());
-  if (S.FileInfos.count(FileName)) {
+  auto [It, Inserted] = S.FileInfos.try_emplace(FileName);
+  if (!Inserted) {
     return make_error<StringError>("When -check is passed, file names must be "
                                    "distinct (duplicate: \"" +
                                        FileName + "\")",
                                    inconvertibleErrorCode());
   }
 
-  auto &FileInfo = S.FileInfos[FileName];
+  auto &FileInfo = It->second;
   LLVM_DEBUG(
       { dbgs() << "Registering COFF file info for \"" << FileName << "\"\n"; });
   for (auto &Sec : G.sections()) {


        


More information about the llvm-commits mailing list