3 ms·
If you use all 8 bits of a byte for data, you need a separate way to store the length, or you need to make everything fixed-width which wastes space. "Varints"
by teraflop 3y ago
If you use all 8 bits of a byte for data, you need a separate way to store the length, or you need to make everything fixed-width which wastes space.
"Varints" or variable-length integers, with 7 bits of data and 1 continuation bit per byte, are used in a fairly wide variety of formats (e.g. Protobuf, SQLite and Lucene). They're compact when most of your integers are small, while still being quite simple and fast to encode/decode.
Faster alternatives tend to be more complicated, and more compact alternatives tend to be slower.
See https://en.wikipedia.org/wiki/Variable-length_quantity https://en.wikipedia.org/wiki/Variable-length_quantity
- joquarky 3y agoI wonder if something resembling this could have been better than how IPv6 attempts to solve the address space problem.
- p1mrx 3y agoVariable-length IP addresses were considered at the time: https://datatracker.ietf.org/doc/html/rfc1752#section-10.2 https://datatracker.ietf.org/doc/html/rfc1752#section-10.2