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-05-18 13:39:08 +00:00
|
|
|
// gas irOptimized: 88845
|
|
|
|
// gas legacy: 85822
|
|
|
|
// gas legacyOptimized: 83608
|
2019-11-07 20:22:58 +00:00
|
|
|
// set_get_length(uint256): 0xFF -> 0
|
2021-05-18 13:39:08 +00:00
|
|
|
// gas irOptimized: 852360
|
|
|
|
// gas legacy: 810327
|
|
|
|
// gas legacyOptimized: 786258
|
2019-11-07 20:22:58 +00:00
|
|
|
// set_get_length(uint256): 0xFFF -> 0
|
2021-05-18 13:39:08 +00:00
|
|
|
// gas irOptimized: 13328532
|
|
|
|
// gas legacy: 12649059
|
|
|
|
// gas legacyOptimized: 12267870
|
2021-03-11 11:17:50 +00:00
|
|
|
// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas #
|