solidity/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol

30 lines
863 B
Solidity
Raw Normal View History

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;
}
}
// ====
// compileViaYul: also
// ----
// set_get_length(uint256): 0 -> 0
// set_get_length(uint256): 1 -> 0
// set_get_length(uint256): 10 -> 0
// set_get_length(uint256): 20 -> 0
// gas irOptimized: 162505
2021-02-12 12:45:15 +00:00
// gas legacy: 141922
// gas legacyOptimized: 139708
// set_get_length(uint256): 0xFF -> 0
// gas irOptimized: 1790350
2021-02-12 12:45:15 +00:00
// gas legacy: 1524427
// gas legacyOptimized: 1500358
// set_get_length(uint256): 0xFFF -> 0
// gas irOptimized: 28390042
2021-02-12 12:45:15 +00:00
// gas legacy: 24115159
// gas legacyOptimized: 23733970
2021-03-11 11:17:50 +00:00
// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas #