elliotgoodrich / SSO-23

Memory optimal Small String Optimization implementation for C++
233 stars 8 forks source link

Isn't add_cap suboptimal? #1

Closed nlyan closed 9 years ago

nlyan commented 9 years ago

It strikes me that the msb of the size field can't be 1 when the msb of the capacity field is 0. If you put these two bits together in the form 0bCS then you can XOR with 0b01 to bring it down to 0b00 for null termination purposes.

elliotgoodrich commented 9 years ago

Good point! It means we can do away with the size_type additions and subtractions. I'll update the implementation and explanation.

elliotgoodrich commented 9 years ago

Updated README and the basic implementation. In doing so I found a few bugs with it which would have caused it to fail when the most significant bit of size is 1.