mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added specificity to data location.
Added the specificity that bytes1[] and bytes differ because of padding only in memory data location. Added extra sentence that they are similar when used in storage data location.
This commit is contained in:
parent
6849774bd7
commit
f30130888e
@ -153,7 +153,8 @@ third-party string libraries. You can also compare two strings by their keccak25
|
||||
concatenate two strings using ``bytes.concat(bytes(s1), bytes(s2))``.
|
||||
|
||||
You should use ``bytes`` over ``bytes1[]`` because it is cheaper,
|
||||
since ``bytes1[]`` adds 31 padding bytes between the elements. As a general rule,
|
||||
since using ``bytes1[]`` in ``memory`` adds 31 padding bytes between the elements. Note that in ``storage``, the
|
||||
padding is absent due to tight packing, see :ref:`bytes and string <bytes-and-string>`. As a general rule,
|
||||
use ``bytes`` for arbitrary-length raw byte data and ``string`` for arbitrary-length
|
||||
string (UTF-8) data. If you can limit the length to a certain number of bytes,
|
||||
always use one of the value types ``bytes1`` to ``bytes32`` because they are much cheaper.
|
||||
|
Loading…
Reference in New Issue
Block a user