Skip to content

Commit 9a59145

Browse files
[memprof] Avoid repeated map lookups (NFC) (llvm#127027)
1 parent fec04f2 commit 9a59145

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Analysis/MemoryProfileInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ void CallStackTrie::addCallStack(
164164
}
165165
// Update existing caller node if it exists.
166166
CallStackTrieNode *Prev = nullptr;
167-
auto Next = Curr->Callers.find(StackId);
168-
if (Next != Curr->Callers.end()) {
167+
auto [Next, Inserted] = Curr->Callers.try_emplace(StackId);
168+
if (!Inserted) {
169169
Prev = Curr;
170170
Curr = Next->second;
171171
Curr->addAllocType(AllocType);
@@ -177,7 +177,7 @@ void CallStackTrie::addCallStack(
177177
}
178178
// Otherwise add a new caller node.
179179
auto *New = new CallStackTrieNode(AllocType);
180-
Curr->Callers[StackId] = New;
180+
Next->second = New;
181181
Curr = New;
182182
}
183183
assert(Curr);

0 commit comments

Comments
 (0)