diff options
author | Sverker Eriksson <[email protected]> | 2014-03-12 20:11:10 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2014-03-14 15:08:23 +0100 |
commit | c543d5bff7fb23c3f44cc4817c0654117de78919 (patch) | |
tree | 2ef05bcb7ea4a167b69a2938009fe25a137cc6aa /lib/erl_interface/doc | |
parent | 8fbe76d64e7d55eb41943484602b928658313a65 (diff) | |
download | otp-c543d5bff7fb23c3f44cc4817c0654117de78919.tar.gz otp-c543d5bff7fb23c3f44cc4817c0654117de78919.tar.bz2 otp-c543d5bff7fb23c3f44cc4817c0654117de78919.zip |
erts: Change external format for maps
to be: 116,Arity, K1,V1,K2,V2,...,Kn,Vn
instead of: 116,Arity, K1,K2,...,Kn, V1,V2,....,Vn
We think this will be better for future internal map structures
like HAMT. Would be bad if we need to iterate twice over HAMT
in term_to_binary, one for keys and one for values.
Diffstat (limited to 'lib/erl_interface/doc')
-rw-r--r-- | lib/erl_interface/doc/src/ei.xml | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/erl_interface/doc/src/ei.xml b/lib/erl_interface/doc/src/ei.xml index 1756ee8a7d..90495eebd6 100644 --- a/lib/erl_interface/doc/src/ei.xml +++ b/lib/erl_interface/doc/src/ei.xml @@ -422,19 +422,18 @@ ei_x_encode_empty_list(&x); <fsummary>Encode a map</fsummary> <desc> <p>This function encodes a map header, with a specified arity. The next - <c>arity</c> terms encoded will be the keys of the map, and the next - <c>arity</c> terms after that will be the corresponding values in - same order.</p> + <c>arity*2</c> terms encoded will be the keys and values of the map + encoded in the following order: <c>K1, V1, K2, V2, ..., Kn, Vn</c>. + </p> <p>E.g. to encode the map <c>#{a => "Apple", b => "Banana"}</c>:</p> <pre> ei_x_encode_map_header(&x, 2); ei_x_encode_atom(&x, "a"); -ei_x_encode_atom(&x, "b"); ei_x_encode_string(&x, "Apple"); +ei_x_encode_atom(&x, "b"); ei_x_encode_string(&x, "Banana"); </pre> - <p>A correctly encoded map can not have duplicate keys, but no check - for duplicate keys is done by this function.</p> + <p>A correctly encoded map can not have duplicate keys.</p> </desc> </func> <func> @@ -664,10 +663,9 @@ ei_x_encode_string(&x, "Banana"); <desc> <p>This function decodes a map header from the binary format. The number of key-value pairs is returned in - <c>arity</c>. Keys and values follows, first all keys and then all values, - which makes a total of <c>arity*2</c> terms. - Keys and values are paired according to their order, the first key - with the first value and so on. If <c>arity</c> is zero, it's an empty map. + <c>*arity</c>. Keys and values follow in the following order: + <c>K1, V1, K2, V2, ..., Kn, Vn</c>. This makes a total of + <c>arity*2</c> terms. If <c>arity</c> is zero, it's an empty map. A correctly encoded map does not have duplicate keys.</p> </desc> </func> |