|
@@ -104,15 +104,9 @@ library Checkpoints {
|
|
|
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
|
|
|
* in the most recent checkpoint.
|
|
|
*/
|
|
|
- function latestCheckpoint(History storage self)
|
|
|
- internal
|
|
|
- view
|
|
|
- returns (
|
|
|
- bool exists,
|
|
|
- uint32 _blockNumber,
|
|
|
- uint224 _value
|
|
|
- )
|
|
|
- {
|
|
|
+ function latestCheckpoint(
|
|
|
+ History storage self
|
|
|
+ ) internal view returns (bool exists, uint32 _blockNumber, uint224 _value) {
|
|
|
uint256 pos = self._checkpoints.length;
|
|
|
if (pos == 0) {
|
|
|
return (false, 0, 0);
|
|
@@ -133,11 +127,7 @@ library Checkpoints {
|
|
|
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
|
|
|
* or by updating the last one.
|
|
|
*/
|
|
|
- function _insert(
|
|
|
- Checkpoint[] storage self,
|
|
|
- uint32 key,
|
|
|
- uint224 value
|
|
|
- ) private returns (uint224, uint224) {
|
|
|
+ function _insert(Checkpoint[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) {
|
|
|
uint256 pos = self.length;
|
|
|
|
|
|
if (pos > 0) {
|
|
@@ -230,11 +220,7 @@ library Checkpoints {
|
|
|
*
|
|
|
* Returns previous value and new value.
|
|
|
*/
|
|
|
- function push(
|
|
|
- Trace224 storage self,
|
|
|
- uint32 key,
|
|
|
- uint224 value
|
|
|
- ) internal returns (uint224, uint224) {
|
|
|
+ function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) {
|
|
|
return _insert(self._checkpoints, key, value);
|
|
|
}
|
|
|
|
|
@@ -268,15 +254,7 @@ library Checkpoints {
|
|
|
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
|
|
|
* in the most recent checkpoint.
|
|
|
*/
|
|
|
- function latestCheckpoint(Trace224 storage self)
|
|
|
- internal
|
|
|
- view
|
|
|
- returns (
|
|
|
- bool exists,
|
|
|
- uint32 _key,
|
|
|
- uint224 _value
|
|
|
- )
|
|
|
- {
|
|
|
+ function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) {
|
|
|
uint256 pos = self._checkpoints.length;
|
|
|
if (pos == 0) {
|
|
|
return (false, 0, 0);
|
|
@@ -297,11 +275,7 @@ library Checkpoints {
|
|
|
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
|
|
|
* or by updating the last one.
|
|
|
*/
|
|
|
- function _insert(
|
|
|
- Checkpoint224[] storage self,
|
|
|
- uint32 key,
|
|
|
- uint224 value
|
|
|
- ) private returns (uint224, uint224) {
|
|
|
+ function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) {
|
|
|
uint256 pos = self.length;
|
|
|
|
|
|
if (pos > 0) {
|
|
@@ -373,11 +347,10 @@ library Checkpoints {
|
|
|
/**
|
|
|
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
|
|
|
*/
|
|
|
- function _unsafeAccess(Checkpoint224[] storage self, uint256 pos)
|
|
|
- private
|
|
|
- pure
|
|
|
- returns (Checkpoint224 storage result)
|
|
|
- {
|
|
|
+ function _unsafeAccess(
|
|
|
+ Checkpoint224[] storage self,
|
|
|
+ uint256 pos
|
|
|
+ ) private pure returns (Checkpoint224 storage result) {
|
|
|
assembly {
|
|
|
mstore(0, self.slot)
|
|
|
result.slot := add(keccak256(0, 0x20), pos)
|
|
@@ -398,11 +371,7 @@ library Checkpoints {
|
|
|
*
|
|
|
* Returns previous value and new value.
|
|
|
*/
|
|
|
- function push(
|
|
|
- Trace160 storage self,
|
|
|
- uint96 key,
|
|
|
- uint160 value
|
|
|
- ) internal returns (uint160, uint160) {
|
|
|
+ function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) {
|
|
|
return _insert(self._checkpoints, key, value);
|
|
|
}
|
|
|
|
|
@@ -436,15 +405,7 @@ library Checkpoints {
|
|
|
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
|
|
|
* in the most recent checkpoint.
|
|
|
*/
|
|
|
- function latestCheckpoint(Trace160 storage self)
|
|
|
- internal
|
|
|
- view
|
|
|
- returns (
|
|
|
- bool exists,
|
|
|
- uint96 _key,
|
|
|
- uint160 _value
|
|
|
- )
|
|
|
- {
|
|
|
+ function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) {
|
|
|
uint256 pos = self._checkpoints.length;
|
|
|
if (pos == 0) {
|
|
|
return (false, 0, 0);
|
|
@@ -465,11 +426,7 @@ library Checkpoints {
|
|
|
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
|
|
|
* or by updating the last one.
|
|
|
*/
|
|
|
- function _insert(
|
|
|
- Checkpoint160[] storage self,
|
|
|
- uint96 key,
|
|
|
- uint160 value
|
|
|
- ) private returns (uint160, uint160) {
|
|
|
+ function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) {
|
|
|
uint256 pos = self.length;
|
|
|
|
|
|
if (pos > 0) {
|
|
@@ -541,11 +498,10 @@ library Checkpoints {
|
|
|
/**
|
|
|
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
|
|
|
*/
|
|
|
- function _unsafeAccess(Checkpoint160[] storage self, uint256 pos)
|
|
|
- private
|
|
|
- pure
|
|
|
- returns (Checkpoint160 storage result)
|
|
|
- {
|
|
|
+ function _unsafeAccess(
|
|
|
+ Checkpoint160[] storage self,
|
|
|
+ uint256 pos
|
|
|
+ ) private pure returns (Checkpoint160 storage result) {
|
|
|
assembly {
|
|
|
mstore(0, self.slot)
|
|
|
result.slot := add(keccak256(0, 0x20), pos)
|