This small library encodes and decodes signed and unsigned leb128 numbers in Common Lisp.
It should be fast, (with the exception of the encode-signed
operation, which has to do a data copy, and use a non-simple array,
so lookup cost is incurred), as simple-array
are used for the
storage of the numbers, and it is iterative, with binary arithmetic
used where possible.
Returns a (simple-array (unsigned-byte 8))
with the leb128
encoding of i
.
Returns an integer decoded from in
. in
can either be a (array
(unsigned-byte 8))
, or a stream of values (unsigned-byte 8)
.
If start
is supplied and a stream passed in, start
number of
bytes will be discarded from the input stream.
Returns two values, the decoded integer, as well as the number of bytes consumed.
Works nearly identically to previously, but only accepts
unsigned-byte
numbers.
Works nearly identically to decode-signed
, returns two values as
well, and takes the same inputs.