2 ms·
What do you mean by "little-endian prefix varint"? Like this? ``` enum VarInt { Byte(u8), Short(u16), Long(u32), LongLong(u64), } ``` I.e. one byte ta
by IshKebab 7y ago
What do you mean by "little-endian prefix varint"? Like this?
```
enum VarInt {
Byte(u8),
Short(u16),
Long(u32),
LongLong(u64),
}
```
I.e. one byte tag followed by the value? It's definitely an option for me but the main issue is that values under 128 now take 2 bytes instead of 1. I guess I could do something like what CBOR does and use 0-251 = literal value, 252 = u8 follows, 253 = u16 follows, 254 = u32 follows, 255 = u64 follow.
- brandmeyer 7y agoIt can be considered a variation on LEB128 that packs all of the continuation bits into the first byte. Ie, two leading ones set in the first byte mean that there are two trailing bytes. https://news.ycombinator.com/item?id=11263378 https://news.ycombinator.com/item?id=11263378 is one description. https://github.com/stoklund/varint https://github.com/stoklund/varint has some benchmarks.
- IshKebab 7y agoAh ok I understand. Might be a little awkward to implement in Javascript given its lack of 64-bit ints, etc, although it does at least have CLZ32!