Skip to content

Commit df09290

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#126851)
1 parent cb3498c commit df09290

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/include/llvm/Analysis/SparsePropagation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,13 @@ SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getValueState(LatticeKey Key) {
244244
template <class LatticeKey, class LatticeVal, class KeyInfo>
245245
void SparseSolver<LatticeKey, LatticeVal, KeyInfo>::UpdateState(LatticeKey Key,
246246
LatticeVal LV) {
247-
auto I = ValueState.find(Key);
248-
if (I != ValueState.end() && I->second == LV)
247+
auto [I, Inserted] = ValueState.try_emplace(Key);
248+
if (!Inserted && I->second == LV)
249249
return; // No change.
250250

251251
// Update the state of the given LatticeKey and add its corresponding LLVM
252252
// value to the work list.
253-
ValueState[Key] = std::move(LV);
253+
I->second = std::move(LV);
254254
if (Value *V = KeyInfo::getValueFromLatticeKey(Key))
255255
ValueWorkList.push_back(V);
256256
}

0 commit comments

Comments
 (0)