News for hackers. Stuff that matters.
Re:Small Strings in Rust: smolstr vs. smartstring by tialaramex on Saturday August 24, 2024 @04:27PM (#41341231)
> I want to say libc++ and maybe MSVC do something along those lines in their std::string implementations.

Here's Raymond Chen on this topic earlier this same year. As a bonus since you're looking at this in August it's more or less correct now, whereas when it was published it had numerous serious errors. Whether the standard library implementation of such an important type should be so complicated that an expert makes numerous errors is another question...

https://devblogs.microsoft.com/oldnewthing/20240510-00/?p=10...

So, libc++ gets closest, 1 flag byte + 22 bytes of text + 1 byte of ASCII NUL = 24 bytes

The others are much worse, larger (32 bytes on modern computers) yet with lower SSO capacity (15 bytes of text).

Re:Small Strings in Rust: smolstr vs. smartstring by aw1621107 on Saturday August 24, 2024 @07:53PM (#41342962)
Huh, I thought MSVC had a libc++-style SSO implementation. Now I have to wonder where I got that mistaken impression :(