4 ms·
I like this a lot. A third approach not mentioned in the article is to use some form of length prefix (which is itself a fixed number of bits long). This is us
by Retr0id 2y ago
I like this a lot.
A third approach not mentioned in the article is to use some form of length prefix (which is itself a fixed number of bits long). This is usually cheaper to decode, but a fixed-length prefix disproportionally "wastes" space in short numbers.
The approach in the article gives the best of both worlds, all while being very cheap to decode. I'm guessing it might also be fairly SIMD-friendly.
- loeg 2y agoI wonder how well branch predictors handle CLZ vs just masking and comparing bytes. I expect the latter to work really well, but who knows how optimized CLZ-derived branches are.
- theamk 2y agothat seems to be "vu128: Efficient variable-length integers" method, as mentioned at the very end of the post?
- Retr0id 2y agoIt's also a bit of a hybrid, just a different trade-off. It's not quite a fixed-length prefix because they have a special-case for single byte values.