https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67503

--- Comment #11 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to radventure from comment #9)
> I understand the "small string optimization" idea. I agree about allocation
> counting. But I don't see space economy, now sizeof(string) is 28 bytes in
> 32-bit environment instead of 4 bytes early.

It is a speed/space compromise. libc++ (the standard library implementation in
llvm) wastes less space, but has to test whether the string is in "small string
mode" for every operation, even read-only ones, whereas in libstdc++ you can
read a string the same way whether it is short or long. Which approach is best
most likely depends on applications, I am not aware of benchmarks about it.

Reply via email to