From c543d5bff7fb23c3f44cc4817c0654117de78919 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson
Date: Wed, 12 Mar 2014 20:11:10 +0100
Subject: 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.
---
lib/erl_interface/doc/src/ei.xml | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
(limited to 'lib/erl_interface/doc')
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);
Encode a map
This function encodes a map header, with a specified arity. The next
- arity terms encoded will be the keys of the map, and the next
- arity terms after that will be the corresponding values in
- same order.
+ arity*2 terms encoded will be the keys and values of the map
+ encoded in the following order: K1, V1, K2, V2, ..., Kn, Vn.
+
E.g. to encode the map #{a => "Apple", b => "Banana"}:
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");
- A correctly encoded map can not have duplicate keys, but no check
- for duplicate keys is done by this function.
+ A correctly encoded map can not have duplicate keys.
@@ -664,10 +663,9 @@ ei_x_encode_string(&x, "Banana");
This function decodes a map header from the binary
format. The number of key-value pairs is returned in
- arity. Keys and values follows, first all keys and then all values,
- which makes a total of arity*2 terms.
- Keys and values are paired according to their order, the first key
- with the first value and so on. If arity is zero, it's an empty map.
+ *arity. Keys and values follow in the following order:
+ K1, V1, K2, V2, ..., Kn, Vn. This makes a total of
+ arity*2 terms. If arity is zero, it's an empty map.
A correctly encoded map does not have duplicate keys.
--
cgit v1.2.3