[llvm] 0a08d71 - [DebugInfo] Avoid repeated hash lookups (NFC) (#132586)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 23 07:37:11 PDT 2025


Author: Kazu Hirata
Date: 2025-03-23T07:37:08-07:00
New Revision: 0a08d71f2e5966b26bce97db69cd3c5640b1642d

URL: https://github.com/llvm/llvm-project/commit/0a08d71f2e5966b26bce97db69cd3c5640b1642d
DIFF: https://github.com/llvm/llvm-project/commit/0a08d71f2e5966b26bce97db69cd3c5640b1642d.diff

LOG: [DebugInfo] Avoid repeated hash lookups (NFC) (#132586)

Added: 
    

Modified: 
    llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
index 95b95a5bbc509..535893b3f1a4c 100644
--- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
@@ -627,14 +627,15 @@ SymbolCache::getSourceFileById(SymIndexId FileId) const {
 
 SymIndexId
 SymbolCache::getOrCreateSourceFile(const FileChecksumEntry &Checksums) const {
-  auto Iter = FileNameOffsetToId.find(Checksums.FileNameOffset);
-  if (Iter != FileNameOffsetToId.end())
+  auto [Iter, Inserted] =
+      FileNameOffsetToId.try_emplace(Checksums.FileNameOffset);
+  if (!Inserted)
     return Iter->second;
 
   SymIndexId Id = SourceFiles.size();
   auto SrcFile = std::make_unique<NativeSourceFile>(Session, Id, Checksums);
   SourceFiles.push_back(std::move(SrcFile));
-  FileNameOffsetToId[Checksums.FileNameOffset] = Id;
+  Iter->second = Id;
   return Id;
 }
 


        


More information about the llvm-commits mailing list