Subject: Re: [boost] [string] Yet another Unicode string class
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2011-02-14 17:55:33


On 14/02/11 19:08, Scott McMurray wrote:
> On Mon, Feb 14, 2011 at 01:53, Mathias Gaunard
> <mathias.gaunard_at_[hidden]> wrote:
>>
>> SBO makes moving a string costly.
>>
>
> How bug a buffer does SBO usually use?

The libc++ string uses 23 bytes (on a 64-bit architecture) by squishing
the length into a single byte for short strings.

I don't see how that makes moves costly, though. The move constructor
for this string simply copies the bytes and zeroes out the source; it
doesn't even need to branch based on whether it's a long or short
string. Perhaps the concern is that such techniques are not defined
behaviour? Or that the use of unions might confuse the optimizer?

John Bytheway