Remove redundant array access in Checkpoints (#5169)

This commit is contained in:
Hadrien Croubois
2024-08-29 22:38:31 +02:00
committed by GitHub
parent 37619479cd
commit 1e7ca3eea6
2 changed files with 4 additions and 4 deletions

View File

@ -142,7 +142,7 @@ library Checkpoints {
// Update or push new checkpoint
if (lastKey == key) {
_unsafeAccess(self, pos - 1)._value = value;
last._value = value;
} else {
self.push(Checkpoint224({_key: key, _value: value}));
}
@ -337,7 +337,7 @@ library Checkpoints {
// Update or push new checkpoint
if (lastKey == key) {
_unsafeAccess(self, pos - 1)._value = value;
last._value = value;
} else {
self.push(Checkpoint208({_key: key, _value: value}));
}
@ -532,7 +532,7 @@ library Checkpoints {
// Update or push new checkpoint
if (lastKey == key) {
_unsafeAccess(self, pos - 1)._value = value;
last._value = value;
} else {
self.push(Checkpoint160({_key: key, _value: value}));
}

View File

@ -147,7 +147,7 @@ function _insert(${opts.checkpointTypeName}[] storage self, ${opts.keyTypeName}
// Update or push new checkpoint
if (lastKey == key) {
_unsafeAccess(self, pos - 1).${opts.valueFieldName} = value;
last.${opts.valueFieldName} = value;
} else {
self.push(${opts.checkpointTypeName}({${opts.keyFieldName}: key, ${opts.valueFieldName}: value}));
}