Skip to content

Commit

Permalink
Remove redundant array access in Checkpoints (#5169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx authored Aug 29, 2024
1 parent 3761947 commit 1e7ca3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions contracts/utils/structs/Checkpoints.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}));
}
Expand Down Expand Up @@ -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}));
}
Expand Down Expand Up @@ -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}));
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate/templates/Checkpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}));
}
Expand Down

0 comments on commit 1e7ca3e

Please sign in to comment.