This is a 7-bit variable length encoding. The first byte of the encoded value has a high bit set to 0, the subsequent bytes have the value 1. This is the way the decoder can determine how many bytes were used to encode the value. Byte order is always unimportant, regardless of machine architecture.
This is an encoding trick that allows you to write as few bytes as possible to encode a value. Thus, a length of 8 bytes with a value from -64 to 63 accepts only one byte. What is common, the range provided by the long is very rarely used in practice.
Gzip-style dense data packing without overhead was the design goal. Also used in the .NET Framework . The processor overhead required for en / decode is not significant. Already much lower than the compression scheme, this is a very small part of the input-output costs.
source share