Remove redundant array access in Checkpoints (#5169)

Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Hadrien Croubois
2024-08-29 22:38:31 +02:00
parent 4f0644c7e8
commit 40dd647022
2 changed files with 4 additions and 4 deletions

View File

@ -142,7 +142,7 @@ library Checkpoints {
// Update or push new checkpoint // Update or push new checkpoint
if (lastKey == key) { if (lastKey == key) {
_unsafeAccess(self, pos - 1)._value = value; last._value = value;
} else { } else {
self.push(Checkpoint224({_key: key, _value: value})); self.push(Checkpoint224({_key: key, _value: value}));
} }
@ -337,7 +337,7 @@ library Checkpoints {
// Update or push new checkpoint // Update or push new checkpoint
if (lastKey == key) { if (lastKey == key) {
_unsafeAccess(self, pos - 1)._value = value; last._value = value;
} else { } else {
self.push(Checkpoint208({_key: key, _value: value})); self.push(Checkpoint208({_key: key, _value: value}));
} }
@ -532,7 +532,7 @@ library Checkpoints {
// Update or push new checkpoint // Update or push new checkpoint
if (lastKey == key) { if (lastKey == key) {
_unsafeAccess(self, pos - 1)._value = value; last._value = value;
} else { } else {
self.push(Checkpoint160({_key: key, _value: value})); 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 // Update or push new checkpoint
if (lastKey == key) { if (lastKey == key) {
_unsafeAccess(self, pos - 1).${opts.valueFieldName} = value; last.${opts.valueFieldName} = value;
} else { } else {
self.push(${opts.checkpointTypeName}({${opts.keyFieldName}: key, ${opts.valueFieldName}: value})); self.push(${opts.checkpointTypeName}({${opts.keyFieldName}: key, ${opts.valueFieldName}: value}));
} }