solidity/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol

27 lines
568 B
Solidity
Raw Normal View History

contract c {
uint[20] spacer;
uint[] dynamic;
function fill() public {
for (uint i = 0; i < 21; ++i)
dynamic.push(i + 1);
}
function halfClear() public {
while (dynamic.length > 5)
dynamic.pop();
}
function fullClear() public { delete dynamic; }
}
// ====
// compileViaYul: also
// ----
// storageEmpty -> 1
// fill() ->
2021-07-01 12:17:27 +00:00
// gas irOptimized: 520360
// gas legacy: 521773
// gas legacyOptimized: 517048
// storageEmpty -> 0
// halfClear() ->
// storageEmpty -> 0
// fullClear() ->
// storageEmpty -> 1