Skip to content

Commit 02b9c97

Browse files
[memprof] Simplify code with MapVector::operator[] (NFC) (llvm#111335)
Note that the following are all equivalent to each other: Map.insert({Key, Value()}).first->second Map.try_emplace(Key).first->second Map[Key]
1 parent 5e7cc37 commit 02b9c97

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

llvm/lib/ProfileData/MemProfReader.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,7 @@ Error RawMemProfReader::mapRawProfileToRecords() {
529529
// first non-inline frame.
530530
for (size_t I = 0; /*Break out using the condition below*/; I++) {
531531
const Frame &F = idToFrame(Callstack[I]);
532-
auto Result =
533-
FunctionProfileData.insert({F.Function, IndexedMemProfRecord()});
534-
IndexedMemProfRecord &Record = Result.first->second;
532+
IndexedMemProfRecord &Record = FunctionProfileData[F.Function];
535533
Record.AllocSites.emplace_back(Callstack, CSId, MIB);
536534

537535
if (!F.IsInlineFrame)
@@ -543,8 +541,7 @@ Error RawMemProfReader::mapRawProfileToRecords() {
543541
for (const auto &[Id, Locs] : PerFunctionCallSites) {
544542
// Some functions may have only callsite data and no allocation data. Here
545543
// we insert a new entry for callsite data if we need to.
546-
auto Result = FunctionProfileData.insert({Id, IndexedMemProfRecord()});
547-
IndexedMemProfRecord &Record = Result.first->second;
544+
IndexedMemProfRecord &Record = FunctionProfileData[Id];
548545
for (LocationPtr Loc : Locs) {
549546
CallStackId CSId = hashCallStack(*Loc);
550547
CSIdToCallStack.insert({CSId, *Loc});

0 commit comments

Comments
 (0)