@@ -619,16 +619,16 @@ MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
619
619
Buffer.append (LinkedToSym->getName ());
620
620
support::endian::write (Buffer, UniqueID, endianness::native);
621
621
StringRef UniqueMapKey = StringRef (Buffer);
622
- EntryNewPair = ELFUniquingMap.insert ( std::make_pair ( UniqueMapKey, nullptr ) );
622
+ EntryNewPair = ELFUniquingMap.try_emplace ( UniqueMapKey);
623
623
} else if (!Section.isSingleStringRef ()) {
624
624
SmallString<128 > Buffer;
625
625
StringRef UniqueMapKey = Section.toStringRef (Buffer);
626
626
SectionLen = UniqueMapKey.size ();
627
- EntryNewPair = ELFUniquingMap.insert ( std::make_pair ( UniqueMapKey, nullptr ) );
627
+ EntryNewPair = ELFUniquingMap.try_emplace ( UniqueMapKey);
628
628
} else {
629
629
StringRef UniqueMapKey = Section.getSingleStringRef ();
630
630
SectionLen = UniqueMapKey.size ();
631
- EntryNewPair = ELFUniquingMap.insert ( std::make_pair ( UniqueMapKey, nullptr ) );
631
+ EntryNewPair = ELFUniquingMap.try_emplace ( UniqueMapKey);
632
632
}
633
633
634
634
if (!EntryNewPair.second )
@@ -696,10 +696,8 @@ MCSectionGOFF *MCContext::getGOFFSection(StringRef Section, SectionKind Kind,
696
696
MCSection *Parent,
697
697
uint32_t Subsection) {
698
698
// 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)
703
701
return Iter->second ;
704
702
705
703
StringRef CachedName = Iter->first ;
@@ -731,9 +729,8 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
731
729
732
730
// Do the lookup, if we have a hit, return it.
733
731
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)
737
734
return Iter->second ;
738
735
739
736
StringRef CachedName = Iter->first .SectionName ;
0 commit comments