@@ -1499,17 +1499,15 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
14991499 continue ;
15001500
15011501 // 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));
15061505
15071506 // Calculate symbol size
15081507 const DataLayout &DL = Global.getDataLayout ();
15091508 uint32_t Size = DL.getTypeAllocSize (Global.getValueType ());
15101509
1511- DataSecEntries[std::string (SecName)]->addDataSecEntry (VarId,
1512- Asm->getSymbol (&Global), Size);
1510+ It->second ->addDataSecEntry (VarId, Asm->getSymbol (&Global), Size);
15131511
15141512 if (Global.hasInitializer ())
15151513 processGlobalInitializer (Global.getInitializer ());
@@ -1609,14 +1607,12 @@ void BTFDebug::processFuncPrototypes(const Function *F) {
16091607 if (F->hasSection ()) {
16101608 StringRef SecName = F->getSection ();
16111609
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));
16161613
16171614 // 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 );
16201616 }
16211617}
16221618
0 commit comments