Skip to content

Commit 72aec1d

Browse files
[IPO] Avoid repeated hash lookups (NFC) (llvm#130708)
1 parent 3692fb6 commit 72aec1d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Transforms/IPO/SampleProfileProbe.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ void PseudoProbeVerifier::verifyProbeFactors(
148148
auto &PrevProbeFactors = FunctionProbeFactors[F->getName()];
149149
for (const auto &I : ProbeFactors) {
150150
float CurProbeFactor = I.second;
151-
if (PrevProbeFactors.count(I.first)) {
152-
float PrevProbeFactor = PrevProbeFactors[I.first];
151+
auto [It, Inserted] = PrevProbeFactors.try_emplace(I.first);
152+
if (!Inserted) {
153+
float PrevProbeFactor = It->second;
153154
if (std::abs(CurProbeFactor - PrevProbeFactor) >
154155
DistributionFactorVariance) {
155156
if (!BannerPrinted) {
@@ -163,7 +164,7 @@ void PseudoProbeVerifier::verifyProbeFactors(
163164
}
164165

165166
// Update
166-
PrevProbeFactors[I.first] = I.second;
167+
It->second = I.second;
167168
}
168169
}
169170

0 commit comments

Comments
 (0)