Skip to content

Commit ab95ed5

Browse files
[IPO] Avoid repeated hash lookups (NFC) (#107796)
1 parent 3940a1b commit ab95ed5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,8 @@ class ProfiledCallGraph {
156156
ProfiledCallGraphEdge Edge(ProfiledFunctions[CallerName],
157157
CalleeIt->second, Weight);
158158
auto &Edges = ProfiledFunctions[CallerName]->Edges;
159-
auto EdgeIt = Edges.find(Edge);
160-
if (EdgeIt == Edges.end()) {
161-
Edges.insert(Edge);
162-
} else {
159+
auto [EdgeIt, Inserted] = Edges.insert(Edge);
160+
if (!Inserted) {
163161
// Accumulate weight to the existing edge.
164162
Edge.Weight += EdgeIt->Weight;
165163
Edges.erase(EdgeIt);

0 commit comments

Comments
 (0)