Skip to content

Commit 8fe6677

Browse files
[Transforms] Avoid repeated hash lookups (NFC)
1 parent 95e38ba commit 8fe6677

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/Transforms/IPO/SampleProfileProbe.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ 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)) {
151+
auto [It, Inserted] = PrevProbeFactors.try_emplace(I.first);
152+
if (!Inserted) {
152153
float PrevProbeFactor = PrevProbeFactors[I.first];
153154
if (std::abs(CurProbeFactor - PrevProbeFactor) >
154155
DistributionFactorVariance) {
@@ -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)