mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6414 from ethereum/chriseth-patch-1
Layout cleanup.
This commit is contained in:
commit
a3a60b8eb9
@ -19,6 +19,8 @@ For contracts that use inheritance, the ordering of state variables is determine
|
|||||||
C3-linearized order of contracts starting with the most base-ward contract. If allowed
|
C3-linearized order of contracts starting with the most base-ward contract. If allowed
|
||||||
by the above rules, state variables from different contracts do share the same storage slot.
|
by the above rules, state variables from different contracts do share the same storage slot.
|
||||||
|
|
||||||
|
The elements of structs and arrays are stored after each other, just as if they were given explicitly.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
When using elements that are smaller than 32 bytes, your contract's gas usage may be higher.
|
When using elements that are smaller than 32 bytes, your contract's gas usage may be higher.
|
||||||
This is because the EVM operates on 32 bytes at a time. Therefore, if the element is smaller
|
This is because the EVM operates on 32 bytes at a time. Therefore, if the element is smaller
|
||||||
@ -36,7 +38,7 @@ by the above rules, state variables from different contracts do share the same s
|
|||||||
``uint128, uint256, uint128``, as the former will only take up two slots of storage whereas the
|
``uint128, uint256, uint128``, as the former will only take up two slots of storage whereas the
|
||||||
latter will take up three.
|
latter will take up three.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
The layout of state variables in storage is considered to be part of the external interface
|
The layout of state variables in storage is considered to be part of the external interface
|
||||||
of Solidity due to the fact that storage pointers can be passed to libraries. This means that
|
of Solidity due to the fact that storage pointers can be passed to libraries. This means that
|
||||||
any change to the rules outlined in this section is considered a breaking change
|
any change to the rules outlined in this section is considered a breaking change
|
||||||
@ -44,8 +46,6 @@ by the above rules, state variables from different contracts do share the same s
|
|||||||
being executed.
|
being executed.
|
||||||
|
|
||||||
|
|
||||||
The elements of structs and arrays are stored after each other, just as if they were given explicitly.
|
|
||||||
|
|
||||||
Mappings and Dynamic Arrays
|
Mappings and Dynamic Arrays
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user