[llvm] f4136b3 - [llvm-diff] Avoid repeated hash lookups (NFC) (#113025)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 14:42:28 PDT 2024
Author: Kazu Hirata
Date: 2024-10-19T14:42:25-07:00
New Revision: f4136b326514b0732054e17eadc646b45925192d
URL: https://github.com/llvm/llvm-project/commit/f4136b326514b0732054e17eadc646b45925192d
DIFF: https://github.com/llvm/llvm-project/commit/f4136b326514b0732054e17eadc646b45925192d.diff
LOG: [llvm-diff] Avoid repeated hash lookups (NFC) (#113025)
Added:
Modified:
llvm/tools/llvm-diff/lib/DifferenceEngine.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp b/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp
index 05cae4b67d7e52..9be0eec7b73f3e 100644
--- a/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-
diff /lib/DifferenceEngine.cpp
@@ -189,11 +189,11 @@ class FunctionDifferenceEngine {
// The returned reference is not permanently valid and should not be stored.
BlockDiffCandidate &getOrCreateBlockDiffCandidate(const BasicBlock *LBB,
const BasicBlock *RBB) {
- auto It = BlockDiffCandidateIndices.find(LBB);
+ auto [It, Inserted] =
+ BlockDiffCandidateIndices.try_emplace(LBB, BlockDiffCandidates.size());
// Check if LBB already has a
diff candidate
- if (It == BlockDiffCandidateIndices.end()) {
+ if (Inserted) {
// Add new one
- BlockDiffCandidateIndices[LBB] = BlockDiffCandidates.size();
BlockDiffCandidates.push_back(
{LBB, RBB, SmallDenseMap<const Value *, const Value *>(), false});
return BlockDiffCandidates.back();
More information about the llvm-commits
mailing list