Skip to content

Commit 17aac7c

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#130236)
1 parent b32cf76 commit 17aac7c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,8 @@ void BlockFrequencyInfoImpl<BT>::initTransitionProbabilities(
15711571
SmallPtrSet<const BlockT *, 2> UniqueSuccs;
15721572
for (const auto SI : children<const BlockT *>(BB)) {
15731573
// Ignore cold blocks
1574-
if (!BlockIndex.contains(SI))
1574+
auto BlockIndexIt = BlockIndex.find(SI);
1575+
if (BlockIndexIt == BlockIndex.end())
15751576
continue;
15761577
// Ignore parallel edges between BB and SI blocks
15771578
if (!UniqueSuccs.insert(SI).second)
@@ -1583,7 +1584,7 @@ void BlockFrequencyInfoImpl<BT>::initTransitionProbabilities(
15831584

15841585
auto EdgeProb =
15851586
Scaled64::getFraction(EP.getNumerator(), EP.getDenominator());
1586-
size_t Dst = BlockIndex.find(SI)->second;
1587+
size_t Dst = BlockIndexIt->second;
15871588
Succs[Src].push_back(std::make_pair(Dst, EdgeProb));
15881589
SumProb[Src] += EdgeProb;
15891590
}

0 commit comments

Comments
 (0)