Skip to content

Commit f4136b3

Browse files
[llvm-diff] Avoid repeated hash lookups (NFC) (#113025)
1 parent ca9f396 commit f4136b3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/tools/llvm-diff/lib/DifferenceEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ class FunctionDifferenceEngine {
189189
// The returned reference is not permanently valid and should not be stored.
190190
BlockDiffCandidate &getOrCreateBlockDiffCandidate(const BasicBlock *LBB,
191191
const BasicBlock *RBB) {
192-
auto It = BlockDiffCandidateIndices.find(LBB);
192+
auto [It, Inserted] =
193+
BlockDiffCandidateIndices.try_emplace(LBB, BlockDiffCandidates.size());
193194
// Check if LBB already has a diff candidate
194-
if (It == BlockDiffCandidateIndices.end()) {
195+
if (Inserted) {
195196
// Add new one
196-
BlockDiffCandidateIndices[LBB] = BlockDiffCandidates.size();
197197
BlockDiffCandidates.push_back(
198198
{LBB, RBB, SmallDenseMap<const Value *, const Value *>(), false});
199199
return BlockDiffCandidates.back();

0 commit comments

Comments
 (0)