Procedurally generate EnumerableSet and EnumerableMap (#3429)

This commit is contained in:
Hadrien Croubois
2022-08-19 14:12:18 +02:00
committed by GitHub
parent c797195f1d
commit 17bc2dabe0
9 changed files with 708 additions and 15 deletions

View File

@ -214,7 +214,15 @@ library EnumerableSet {
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
@ -325,7 +333,7 @@ library EnumerableSet {
}
/**
* @dev Returns the number of values on the set. O(1).
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);