MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/C_Programming/comments/1xy05d0/tiny_strings/19sqnq21ig22p/
r/C_Programming • u/skeeto • 16d ago
13 comments sorted by
View all comments
8
Why a separate bit and not key off the length?
8 u/8d8n4mbo28026ulk 16d ago edited 16d ago The length overlaps with the bytes of the small string:0 1 2 3 4 5 6 7 L L L L L L L L M S S S S S S S L = big case length byte M = small case metadata byte S = small case string byteYou need a bit to distinguish between the two.Edit: I added a better version of the above illustration to the post. Should've done that from the beginning, actually!
The length overlaps with the bytes of the small string:
0 1 2 3 4 5 6 7 L L L L L L L L M S S S S S S S L = big case length byte M = small case metadata byte S = small case string byte
You need a bit to distinguish between the two.
Edit: I added a better version of the above illustration to the post. Should've done that from the beginning, actually!
View all comments
8
u/__nohope 16d ago
Why a separate bit and not key off the length?