[DWARFLinker] Avoid repeated hash lookups (NFC) (#108737)

This commit is contained in:
Kazu Hirata 2024-09-15 01:20:48 -07:00 committed by GitHub
parent 56f061f71b
commit ddca79aaee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -371,16 +371,11 @@ public:
/// If descriptor does not exist then creates it.
SectionDescriptor &
getOrCreateSectionDescriptor(DebugSectionKind SectionKind) {
SectionsSetTy::iterator It = SectionDescriptors.find(SectionKind);
auto [It, Inserted] = SectionDescriptors.try_emplace(SectionKind);
if (It == SectionDescriptors.end()) {
SectionDescriptor *Section =
new SectionDescriptor(SectionKind, GlobalData, Format, Endianness);
auto Result = SectionDescriptors.try_emplace(SectionKind, Section);
assert(Result.second);
It = Result.first;
}
if (Inserted)
It->second = std::make_shared<SectionDescriptor>(SectionKind, GlobalData,
Format, Endianness);
return *It->second;
}