mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10775 from ethereum/useRoundUpInArrayAlloc
Use round up function.
This commit is contained in:
commit
31ee06d945
@ -2056,8 +2056,7 @@ string YulUtilFunctions::arrayAllocationSizeFunction(ArrayType const& _type)
|
||||
// Make sure we can allocate memory without overflow
|
||||
if gt(length, 0xffffffffffffffff) { <panic>() }
|
||||
<?byteArray>
|
||||
// round up
|
||||
size := and(add(length, 0x1f), not(0x1f))
|
||||
size := <roundUp>(length)
|
||||
<!byteArray>
|
||||
size := mul(length, 0x20)
|
||||
</byteArray>
|
||||
@ -2070,6 +2069,7 @@ string YulUtilFunctions::arrayAllocationSizeFunction(ArrayType const& _type)
|
||||
w("functionName", functionName);
|
||||
w("panic", panicFunction(PanicCode::ResourceError));
|
||||
w("byteArray", _type.isByteArray());
|
||||
w("roundUp", roundUpFunction());
|
||||
w("dynamic", _type.isDynamicallySized());
|
||||
return w.render();
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
@ -88,8 +88,7 @@ object \"C_11\" {
|
||||
// Make sure we can allocate memory without overflow
|
||||
if gt(length, 0xffffffffffffffff) { panic_error_0x41() }
|
||||
|
||||
// round up
|
||||
size := and(add(length, 0x1f), not(0x1f))
|
||||
size := round_up_to_mul_of_32(length)
|
||||
|
||||
// add length slot
|
||||
size := add(size, 0x20)
|
||||
|
@ -88,8 +88,7 @@ object \"C_11\" {
|
||||
// Make sure we can allocate memory without overflow
|
||||
if gt(length, 0xffffffffffffffff) { panic_error_0x41() }
|
||||
|
||||
// round up
|
||||
size := and(add(length, 0x1f), not(0x1f))
|
||||
size := round_up_to_mul_of_32(length)
|
||||
|
||||
// add length slot
|
||||
size := add(size, 0x20)
|
||||
|
@ -14,9 +14,9 @@ contract C {
|
||||
}
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 1173600
|
||||
// codeDepositCost: 1174000
|
||||
// executionCost: 1221
|
||||
// totalCost: 1174821
|
||||
// totalCost: 1175221
|
||||
// external:
|
||||
// a(): 1130
|
||||
// b(uint256): infinite
|
||||
|
Loading…
Reference in New Issue
Block a user