[llvm] 9a33488 - [DWARFLinker] Avoid repeated hash lookups (NFC) (#109604)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 06:42:32 PDT 2024
Author: Kazu Hirata
Date: 2024-09-23T06:42:28-07:00
New Revision: 9a3348856ced274b9c7136d6726a18ca8975dad1
URL: https://github.com/llvm/llvm-project/commit/9a3348856ced274b9c7136d6726a18ca8975dad1
DIFF: https://github.com/llvm/llvm-project/commit/9a3348856ced274b9c7136d6726a18ca8975dad1.diff
LOG: [DWARFLinker] Avoid repeated hash lookups (NFC) (#109604)
Added:
Modified:
llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp
index 3030aa2c39b234..9a115ace6ce3a3 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp
@@ -287,12 +287,12 @@ uint32_t TypeUnit::addFileNameIntoLinetable(StringEntry *Dir,
}
uint32_t FileIdx = 0;
- FilenamesMapTy::iterator FileEntry = FileNamesMap.find({FileName, DirIdx});
- if (FileEntry == FileNamesMap.end()) {
+ auto [FileEntry, Inserted] = FileNamesMap.try_emplace({FileName, DirIdx});
+ if (Inserted) {
// We currently do not support more than UINT32_MAX files.
assert(LineTable.Prologue.FileNames.size() < UINT32_MAX);
FileIdx = LineTable.Prologue.FileNames.size();
- FileNamesMap.insert({{FileName, DirIdx}, FileIdx});
+ FileEntry->second = FileIdx;
LineTable.Prologue.FileNames.push_back(DWARFDebugLine::FileNameEntry());
LineTable.Prologue.FileNames.back().Name = DWARFFormValue::createFromPValue(
dwarf::DW_FORM_string, FileName->getKeyData());
More information about the llvm-commits
mailing list