Skip to content

Commit 323b3a7

Browse files
[Passes] Avoid repeated hash lookups (NFC) (#110790)
1 parent abaa824 commit 323b3a7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,13 +2040,14 @@ DotCfgDiff::DotCfgDiff(StringRef Title, const FuncDataT<DCData> &Before,
20402040
StringRef Colour = E.second;
20412041

20422042
// Look for an edge from Source to Sink
2043-
if (EdgeLabels.count(SourceSink) == 0)
2044-
EdgeLabels.insert({SourceSink, colourize(Value.str(), Colour)});
2043+
auto [It, Inserted] = EdgeLabels.try_emplace(SourceSink);
2044+
if (Inserted)
2045+
It->getValue() = colourize(Value.str(), Colour);
20452046
else {
2046-
StringRef V = EdgeLabels.find(SourceSink)->getValue();
2047+
StringRef V = It->getValue();
20472048
std::string NV = colourize(V.str() + " " + Value.str(), Colour);
20482049
Colour = CommonColour;
2049-
EdgeLabels[SourceSink] = NV;
2050+
It->getValue() = NV;
20502051
}
20512052
SourceNode.addEdge(SinkNode, Value, Colour);
20522053
}

0 commit comments

Comments
 (0)