Skip to content

Commit da36cad

Browse files
committed
add docs
1 parent 78f93a8 commit da36cad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

contracts/utils/Arrays.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,22 @@ library Arrays {
103103
return slot.getUint256Slot();
104104
}
105105

106+
/**
107+
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
108+
*
109+
* WARNING: Only use if you are certain `pos` is lower than the array length.
110+
*/
106111
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
107112
assembly {
108113
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
109114
}
110115
}
111116

117+
/**
118+
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
119+
*
120+
* WARNING: Only use if you are certain `pos` is lower than the array length.
121+
*/
112122
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
113123
assembly {
114124
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))

0 commit comments

Comments
 (0)