Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
edflsafoiewq
on Jan 31, 2020
|
parent
|
context
|
favorite
| on:
Libc++'s Implementation of std::string
IIRC you store (23 - size) in the last byte in "small string" mode, so when the size gets to 23, the last byte is 0, doubling as the null terminator.
lilyball
on Jan 31, 2020
[–]
Surely it must be (23 - size) << 1, otherwise you won't guarantee a 0 in the LSB.
SamReidHughes
on Jan 31, 2020
|
parent
|
next
[–]
On little endian systems it uses two MSb's, on big endian systems it uses two LSb's. There are actually two flag bits.
edflsafoiewq
on Jan 31, 2020
|
parent
|
prev
[–]
If you use the LSB of the last byte for a flag, you're using the 56th bit of one of the {data,size,cap} words. I'd use the MSB in this case, since you can shift that off easier.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: