Hacker News new | ask | show | jobs
by masklinn 165 days ago
C++ strings are not "optimized so". C++ strings (generally) do SSO (up to 23 bytes depending on implementation), these also do SSO but only 8 bytes (to a total of 12), the first 4 bytes are always stored inline for fast lookup even when the rest of the string is on the heap (in which case they're duplicated), and the strings are limited to 4GB (32 bits length). IIRC they also have a bunch of other limitations (e.g. they're not really extensible, by design).

Which is why they're "everywhere"... in databases, especially columnar storage.

1 comments

Yes. Sorry. That was not 100% correct. Still, your words (my emphasis)

>C++ strings are not "optimized so". C++ strings (generally) do SSO (up to 23 bytes depending on implementation), these also do SSO but only 8 bytes (to a total of 12)

That is what I meant. I would (like you did) call it SSO still.