Update declaration of memory safe assembly blocks (#5172)

Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Hadrien Croubois
2024-08-29 23:07:17 +02:00
parent 40dd647022
commit 0f09ebad09
32 changed files with 91 additions and 182 deletions

View File

@ -86,8 +86,7 @@ function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure
* @dev Pointer to the memory location of the first element of \`array\`.
*/
function _begin(uint256[] memory array) private pure returns (uint256 ptr) {
/// @solidity memory-safe-assembly
assembly {
assembly ("memory-safe") {
ptr := add(array, 0x20)
}
}
@ -323,8 +322,7 @@ function unsafeAccess(${type}[] storage arr, uint256 pos) internal pure returns
type,
)}Slot storage) {
bytes32 slot;
/// @solidity memory-safe-assembly
assembly {
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).get${capitalize(type)}Slot();
@ -351,8 +349,7 @@ const unsafeSetLength = type => `\
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(${type}[] storage array, uint256 len) internal {
/// @solidity memory-safe-assembly
assembly {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}