From da36cad1b416d5d7410cb46bd7d4818e2d398217 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 14 Jun 2023 23:10:29 -0300 Subject: [PATCH] add docs --- contracts/utils/Arrays.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contracts/utils/Arrays.sol b/contracts/utils/Arrays.sol index 1dc9d9dd570..f4ef45645a8 100644 --- a/contracts/utils/Arrays.sol +++ b/contracts/utils/Arrays.sol @@ -103,12 +103,22 @@ library Arrays { return slot.getUint256Slot(); } + /** + * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. + * + * WARNING: Only use if you are certain `pos` is lower than the array length. + */ function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } + /** + * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. + * + * WARNING: Only use if you are certain `pos` is lower than the array length. + */ function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20)))