|
@@ -111,15 +111,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);
|
|
@@ -140,11 +134,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) {
|
|
@@ -237,11 +227,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);
|
|
|
}
|
|
|
|
|
@@ -275,15 +261,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);
|
|
@@ -304,11 +282,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) {
|
|
@@ -380,11 +354,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)
|
|
@@ -405,11 +378,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);
|
|
|
}
|
|
|
|
|
@@ -443,15 +412,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);
|
|
@@ -472,11 +433,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) {
|
|
@@ -548,11 +505,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)
|