diff options
author | Rob Pike <r@golang.org> | 2009-07-28 17:20:19 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-07-28 17:20:19 -0700 |
commit | 2371820a800563d0a7a5a96e34f9e158bc81eb24 (patch) | |
tree | e28e2153d863e5f8d66e6f67ff3d6ea183686f79 /src/pkg/gob/encoder.go | |
parent | cc74f077abe6bb64b8200834dc009a426555d17c (diff) | |
download | golang-2371820a800563d0a7a5a96e34f9e158bc81eb24.tar.gz |
change the encoding of uints to simplify overflow checking and to make them
easier and faster to read. they are now either a one-byte value or a n-byte value
preceded by a byte holding -n.
R=rsc
DELTA=150 (45 added, 7 deleted, 98 changed)
OCL=32381
CL=32387
Diffstat (limited to 'src/pkg/gob/encoder.go')
-rw-r--r-- | src/pkg/gob/encoder.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pkg/gob/encoder.go b/src/pkg/gob/encoder.go index 1a401eb1c..3d8f3928c 100644 --- a/src/pkg/gob/encoder.go +++ b/src/pkg/gob/encoder.go @@ -78,11 +78,11 @@ The rest of this comment documents the encoding, details that are not important for most users. Details are presented bottom-up. - An unsigned integer is encoded as an arbitrary-precision, variable-length sequence - of bytes. It is sent in little-endian order (low bits first), with seven bits per - byte. The high bit of each byte is zero, except that the high bit of the final - (highest precision) byte of the encoding will be set. Thus 0 is transmitted as - (80), 7 is transmitted as (87) and 256=2*128 is transmitted as (00 82). + An unsigned integer is sent one of two ways. If it is less than 128, it is sent + as a byte with that value. Otherwise it is sent as a minimal-length big-endian + (high byte first) byte stream holding the value, preceded by one byte holding the + byte count, negated. Thus 0 is transmitted as (00), 7 is transmitted as (07) and + 256 is transmitted as (FE 01 00). A boolean is encoded within an unsigned integer: 0 for false, 1 for true. |