aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-12-08 06:31:58 +0800
committerchriseth <c@ethdev.com>2015-12-08 06:35:39 +0800
commit92c789a89cdcdb9ef95303f0991e06a833483aaa (patch)
treefb26beda629c24ff2b36d4495af8c348c0cd4e09 /docs
parent99bb8a9740b3d8105b629c0f6e76557efb0b8620 (diff)
downloaddexon-solidity-92c789a89cdcdb9ef95303f0991e06a833483aaa.tar
dexon-solidity-92c789a89cdcdb9ef95303f0991e06a833483aaa.tar.gz
dexon-solidity-92c789a89cdcdb9ef95303f0991e06a833483aaa.tar.bz2
dexon-solidity-92c789a89cdcdb9ef95303f0991e06a833483aaa.tar.lz
dexon-solidity-92c789a89cdcdb9ef95303f0991e06a833483aaa.tar.xz
dexon-solidity-92c789a89cdcdb9ef95303f0991e06a833483aaa.tar.zst
dexon-solidity-92c789a89cdcdb9ef95303f0991e06a833483aaa.zip
Added some lost changes.
Diffstat (limited to 'docs')
-rw-r--r--docs/frequently-asked-questions.rst7
-rw-r--r--docs/style-guide.rst2
-rw-r--r--docs/types.rst6
3 files changed, 14 insertions, 1 deletions
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index 3ee71e64..94491381 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -547,6 +547,13 @@ Can a regular (i.e. non-contract) ethereum account be closed permanently like a
No. Non-contract accounts "exist" as long as the private key is known by
someone or can be generated in some way.
+What is the difference between `bytes` and `byte[]`?
+====================================================
+
+`bytes` is usually more efficient: When used as arguments to functions (i.e. in
+CALLDATA) or in memory, every single element of a `byte[]` is padded to 32
+bytes which wastes 31 bytes per element.
+
******************
Advanced Questions
******************
diff --git a/docs/style-guide.rst b/docs/style-guide.rst
index 0d7e900f..cd901e63 100644
--- a/docs/style-guide.rst
+++ b/docs/style-guide.rst
@@ -513,7 +513,7 @@ No::
x |= y&&z;
* Operators with a higher priority than others can exclude surrounding
- whitespace in order to denote precidence. This is meant to allow for
+ whitespace in order to denote precedence. This is meant to allow for
improved readability for complex statement. You should always use the same
amount of whitespace on either side of an operator:
diff --git a/docs/types.rst b/docs/types.rst
index a8092403..9811df69 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -119,6 +119,10 @@ Dynamically-sized byte array
`string`:
Dynamically-sized UTF8-encoded string, see :ref:`arrays`. Not a value-type!
+As a rule of thumb, 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 `bytes1` to `bytes32` because they are much cheaper.
+
.. index:: literal, literal;integer
Integer Literals
@@ -261,6 +265,8 @@ Variables of type `bytes` and `string` are special arrays. A `bytes` is similar
but it is packed tightly in calldata. `string` is equal to `bytes` but does not allow
length or index access (for now).
+So `bytes` should always be preferred over `byte[]` because it is cheaper.
+
.. note::
If you want to access the byte-representation of a string `s`, use
`bytes(s).length` / `bytes(s)[7] = 'x';`. Keep in mind