[llvm] [DWARFLinker] Avoid repeated hash lookups (NFC) (PR #109604)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 22 21:07:40 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/109604
None
>From 51acbe6609863393933122e6dfa9eb0390d3fd4a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 22 Sep 2024 08:12:39 -0700
Subject: [PATCH] [DWARFLinker] Avoid repeated hash lookups (NFC)
---
llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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