From 829ff5c3c543eb66407c9f813ce8de89319ea701 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 27 Jun 2023 21:25:09 +0200 Subject: [PATCH] Tweaks --- preserves-zerocopy.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/preserves-zerocopy.md b/preserves-zerocopy.md index e26bedc..b5cf07d 100644 --- a/preserves-zerocopy.md +++ b/preserves-zerocopy.md @@ -153,19 +153,22 @@ points, while for `ByteString` it is the raw data contained within the Encoded data of length 7 bytes or shorter is represented as an immediate `Ref` with tag 4 (`String`), 6 (`ByteString`) or 8 (`Symbol`). The lower 4 bits of the 60-bit payload are the length of the encoded data; the upper 56 -bits are 7 bytes of data, with the first data byte in the uppermost byte. +bits are 7 bytes of data, with the first data byte in the lowest byte, so +that the order of data bytes in memory in an immediate encoding matches the +order in a `Buf` encoding. Data longer than 7 bytes is represented with a `Ref` with tag 5, 7 or 9 pointing to a `Buf` containing the bytes of encoded data. Empty values -(length 0) *MUST* be encoded using immediate `Ref` form. +(length 0) *MUST* be encoded using pointer `Ref` form with special offset +zero. For example, Value Ref (64-bit) Buf (hex bytes) ----------------------------------------- ---------------- ---------------- - "" 0000000000000004 - - #"" 0000000000000006 - - || 0000000000000008 - + "" 0000000000000005 - + #"" 0000000000000007 - + || 0000000000000009 - "Hello" 48656C6C6F000054 - "a\0a" 6100610000000034 -