@@ -619,16 +619,16 @@ MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
619619 Buffer.append (LinkedToSym->getName ());
620620 support::endian::write (Buffer, UniqueID, endianness::native);
621621 StringRef UniqueMapKey = StringRef (Buffer);
622- EntryNewPair = ELFUniquingMap.insert ( std::make_pair ( UniqueMapKey, nullptr ) );
622+ EntryNewPair = ELFUniquingMap.try_emplace ( UniqueMapKey);
623623 } else if (!Section.isSingleStringRef ()) {
624624 SmallString<128 > Buffer;
625625 StringRef UniqueMapKey = Section.toStringRef (Buffer);
626626 SectionLen = UniqueMapKey.size ();
627- EntryNewPair = ELFUniquingMap.insert ( std::make_pair ( UniqueMapKey, nullptr ) );
627+ EntryNewPair = ELFUniquingMap.try_emplace ( UniqueMapKey);
628628 } else {
629629 StringRef UniqueMapKey = Section.getSingleStringRef ();
630630 SectionLen = UniqueMapKey.size ();
631- EntryNewPair = ELFUniquingMap.insert ( std::make_pair ( UniqueMapKey, nullptr ) );
631+ EntryNewPair = ELFUniquingMap.try_emplace ( UniqueMapKey);
632632 }
633633
634634 if (!EntryNewPair.second )
@@ -696,10 +696,8 @@ MCSectionGOFF *MCContext::getGOFFSection(StringRef Section, SectionKind Kind,
696696 MCSection *Parent,
697697 uint32_t Subsection) {
698698 // Do the lookup. If we don't have a hit, return a new section.
699- auto IterBool =
700- GOFFUniquingMap.insert (std::make_pair (Section.str (), nullptr ));
701- auto Iter = IterBool.first ;
702- if (!IterBool.second )
699+ auto [Iter, Inserted] = GOFFUniquingMap.try_emplace (Section.str ());
700+ if (!Inserted)
703701 return Iter->second ;
704702
705703 StringRef CachedName = Iter->first ;
@@ -731,9 +729,8 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
731729
732730 // Do the lookup, if we have a hit, return it.
733731 COFFSectionKey T{Section, COMDATSymName, Selection, UniqueID};
734- auto IterBool = COFFUniquingMap.insert (std::make_pair (T, nullptr ));
735- auto Iter = IterBool.first ;
736- if (!IterBool.second )
732+ auto [Iter, Inserted] = COFFUniquingMap.try_emplace (T);
733+ if (!Inserted)
737734 return Iter->second ;
738735
739736 StringRef CachedName = Iter->first .SectionName ;
0 commit comments