Skip to content

Commit ddca79a

Browse files
[DWARFLinker] Avoid repeated hash lookups (NFC) (#108737)
1 parent 56f061f commit ddca79a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

llvm/lib/DWARFLinker/Parallel/OutputSections.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,11 @@ class OutputSections {
371371
/// If descriptor does not exist then creates it.
372372
SectionDescriptor &
373373
getOrCreateSectionDescriptor(DebugSectionKind SectionKind) {
374-
SectionsSetTy::iterator It = SectionDescriptors.find(SectionKind);
375-
376-
if (It == SectionDescriptors.end()) {
377-
SectionDescriptor *Section =
378-
new SectionDescriptor(SectionKind, GlobalData, Format, Endianness);
379-
auto Result = SectionDescriptors.try_emplace(SectionKind, Section);
380-
assert(Result.second);
374+
auto [It, Inserted] = SectionDescriptors.try_emplace(SectionKind);
381375

382-
It = Result.first;
383-
}
376+
if (Inserted)
377+
It->second = std::make_shared<SectionDescriptor>(SectionKind, GlobalData,
378+
Format, Endianness);
384379

385380
return *It->second;
386381
}

0 commit comments

Comments
 (0)