Skip to content

Commit 3e8b175

Browse files
committed
[IR] Avoid redundant map lookup [NFC]
Use the iterator returned by MapVector::insert to update the value in the map, instead of a second redundant map lookup.
1 parent f69c83f commit 3e8b175

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/IR/Operator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ bool GEPOperator::collectOffset(
229229
// Insert an initial offset of 0 for V iff none exists already, then
230230
// increment the offset by IndexedSize.
231231
if (!IndexedSize.isZero()) {
232-
VariableOffsets.insert({V, APInt(BitWidth, 0)});
233-
VariableOffsets[V] += IndexedSize;
232+
auto *It = VariableOffsets.insert({V, APInt(BitWidth, 0)}).first;
233+
It->second += IndexedSize;
234234
}
235235
}
236236
return true;

0 commit comments

Comments
 (0)