News for hackers. Stuff that matters.
Re:Libc++'s Implementation of std::string by edflsafoiewq on Thursday January 30, 2020 @09:54PM (#22198565)
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.
Re:Libc++'s Implementation of std::string by lilyball on Thursday January 30, 2020 @10:55PM (#22198881)
Surely it must be (23 - size) << 1, otherwise you won't guarantee a 0 in the LSB.
Re:Libc++'s Implementation of std::string by SamReidHughes on Thursday January 30, 2020 @11:24PM (#22199037)
On little endian systems it uses two MSb's, on big endian systems it uses two LSb's. There are actually two flag bits.
Re:Libc++'s Implementation of std::string by edflsafoiewq on Thursday January 30, 2020 @11:10PM (#22198960)
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.