mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
23 lines
592 B
Solidity
23 lines
592 B
Solidity
// Tests transition between short and long encoding
|
|
contract c {
|
|
bytes data;
|
|
|
|
function test() public returns (uint256) {
|
|
for (uint8 i = 1; i < 40; i++) {
|
|
data.push(bytes1(i));
|
|
if (data.length != i) return 0x1000 + i;
|
|
if (data[data.length - 1] != bytes1(i)) return i;
|
|
}
|
|
for (uint8 i = 1; i < 40; i++)
|
|
if (data[i - 1] != bytes1(i)) return 0x1000000 + i;
|
|
return 0;
|
|
}
|
|
}
|
|
// ====
|
|
// compileViaYul: also
|
|
// ----
|
|
// test() -> 0
|
|
// gas irOptimized: 398636
|
|
// gas legacy: 565428
|
|
// gas legacyOptimized: 552330
|