2019-11-07 20:22:58 +00:00
|
|
|
contract C {
|
|
|
|
uint[] storageArray;
|
|
|
|
function set_get_length(uint256 len) public returns (uint256) {
|
|
|
|
while(storageArray.length < len)
|
|
|
|
storageArray.push();
|
|
|
|
while(storageArray.length > 0)
|
|
|
|
storageArray.pop();
|
|
|
|
return storageArray.length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ====
|
2020-11-24 23:25:42 +00:00
|
|
|
// compileViaYul: also
|
2019-11-07 20:22:58 +00:00
|
|
|
// ----
|
|
|
|
// set_get_length(uint256): 0 -> 0
|
|
|
|
// set_get_length(uint256): 1 -> 0
|
|
|
|
// set_get_length(uint256): 10 -> 0
|
|
|
|
// set_get_length(uint256): 20 -> 0
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas irOptimized: 162779
|
|
|
|
// gas legacy: 141922
|
|
|
|
// gas legacyOptimized: 139708
|
2019-11-07 20:22:58 +00:00
|
|
|
// set_get_length(uint256): 0xFF -> 0
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas irOptimized: 1792504
|
|
|
|
// gas legacy: 1524427
|
|
|
|
// gas legacyOptimized: 1500358
|
2019-11-07 20:22:58 +00:00
|
|
|
// set_get_length(uint256): 0xFFF -> 0
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas irOptimized: 28422916
|
|
|
|
// gas legacy: 24115159
|
|
|
|
// gas legacyOptimized: 23733970
|
|
|
|
// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas #
|