@@ -1499,17 +1499,15 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
1499
1499
continue ;
1500
1500
1501
1501
// Find or create a DataSec
1502
- if (DataSecEntries.find (std::string (SecName)) == DataSecEntries.end ()) {
1503
- DataSecEntries[std::string (SecName)] =
1504
- std::make_unique<BTFKindDataSec>(Asm, std::string (SecName));
1505
- }
1502
+ auto [It, Inserted] = DataSecEntries.try_emplace (std::string (SecName));
1503
+ if (Inserted)
1504
+ It->second = std::make_unique<BTFKindDataSec>(Asm, std::string (SecName));
1506
1505
1507
1506
// Calculate symbol size
1508
1507
const DataLayout &DL = Global.getDataLayout ();
1509
1508
uint32_t Size = DL.getTypeAllocSize (Global.getValueType ());
1510
1509
1511
- DataSecEntries[std::string (SecName)]->addDataSecEntry (VarId,
1512
- Asm->getSymbol (&Global), Size);
1510
+ It->second ->addDataSecEntry (VarId, Asm->getSymbol (&Global), Size);
1513
1511
1514
1512
if (Global.hasInitializer ())
1515
1513
processGlobalInitializer (Global.getInitializer ());
@@ -1609,14 +1607,12 @@ void BTFDebug::processFuncPrototypes(const Function *F) {
1609
1607
if (F->hasSection ()) {
1610
1608
StringRef SecName = F->getSection ();
1611
1609
1612
- if (DataSecEntries.find (std::string (SecName)) == DataSecEntries.end ()) {
1613
- DataSecEntries[std::string (SecName)] =
1614
- std::make_unique<BTFKindDataSec>(Asm, std::string (SecName));
1615
- }
1610
+ auto [It, Inserted] = DataSecEntries.try_emplace (std::string (SecName));
1611
+ if (Inserted)
1612
+ It->second = std::make_unique<BTFKindDataSec>(Asm, std::string (SecName));
1616
1613
1617
1614
// We really don't know func size, set it to 0.
1618
- DataSecEntries[std::string (SecName)]->addDataSecEntry (FuncId,
1619
- Asm->getSymbol (F), 0 );
1615
+ It->second ->addDataSecEntry (FuncId, Asm->getSymbol (F), 0 );
1620
1616
}
1621
1617
}
1622
1618
0 commit comments