From: Peter Dimov (pdimov_at_[hidden])
Date: 2019-12-04 18:23:52
Andrey Semashev wrote:
> > The idea here is that you win one byte by reusing the last byte of the
> > storage as the size, overlapping it with the null terminator in the
> > size() == N case (because capacity - size becomes 0).
> I'm not sure this would actually be beneficial in terms if performance.
> Ignoring the fact that size() becomes more expensive, and this is a
> relatively often used function, you also have to access the tail of the
> storage, which is likely on a different cache line than the beginning of
> the string.
Yes, probably. As I said, it's not clear that we should bother with it (I
wouldn't), but it at least gives consistent space savings for all short
That said, one could use it for N < 32, when the size will be in the same
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk