Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 15, 2024

@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/112298.diff

1 Files Affected:

  • (modified) llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp (+3-3)
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.

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazutakahirata kazutakahirata merged commit c5c27d8 into llvm:main Oct 15, 2024
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_DebugInfo branch October 15, 2024 14:34
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants