Skip to content

Commit abaa824

Browse files
[memprof] Avoid repeated hash lookups (NFC) (#110789)
1 parent e353195 commit abaa824

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

llvm/lib/ProfileData/MemProfReader.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,10 @@ CallStackMap readStackInfo(const char *Ptr) {
193193
// addresses.
194194
bool mergeStackMap(const CallStackMap &From, CallStackMap &To) {
195195
for (const auto &[Id, Stack] : From) {
196-
auto I = To.find(Id);
197-
if (I == To.end()) {
198-
To[Id] = Stack;
199-
} else {
200-
// Check that the PCs are the same (in order).
201-
if (Stack != I->second)
202-
return true;
203-
}
196+
auto [It, Inserted] = To.try_emplace(Id, Stack);
197+
// Check that the PCs are the same (in order).
198+
if (!Inserted && Stack != It->second)
199+
return true;
204200
}
205201
return false;
206202
}

0 commit comments

Comments
 (0)