[llvm] c5c27d8 - [DebugInfo] Avoid repeated hash lookups (NFC) (#112298)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 07:34:55 PDT 2024


Author: Kazu Hirata
Date: 2024-10-15T07:34:50-07:00
New Revision: c5c27d8025561ea9ba09950d0673170e70eca281

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

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

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 1a31aa206dfcc6..463b9ebe3cbff5 100644
--- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
@@ -447,11 +447,11 @@ SymbolCache::findPublicSymbolBySectOffset(uint32_t Sect, uint32_t Offset) {
 std::vector<SymbolCache::LineTableEntry>
 SymbolCache::findLineTable(uint16_t Modi) const {
   // Check if this module has already been added.
-  auto LineTableIter = LineTable.find(Modi);
-  if (LineTableIter != LineTable.end())
+  auto [LineTableIter, Inserted] = LineTable.try_emplace(Modi);
+  if (!Inserted)
     return LineTableIter->second;
 
-  std::vector<LineTableEntry> &ModuleLineTable = LineTable[Modi];
+  std::vector<LineTableEntry> &ModuleLineTable = LineTableIter->second;
 
   // If there is an error or there are no lines, just return the
   // empty vector.


        


More information about the llvm-commits mailing list