[llvm] [DebugInfo] Avoid repeated hash lookups (NFC) (PR #112298)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 14 20:28:49 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/112298
None
>From c326c3d76eeb1cee0e42075ab15cb6ca01b77d04 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 14 Oct 2024 07:11:32 -0700
Subject: [PATCH] [DebugInfo] Avoid repeated hash lookups (NFC)
---
llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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