On 4/8/12 10:03 AM, Manu wrote:
29 bits? ...not 31?

Sorry, 31 indeed.

How does this implementation actually work? On 32/64 bits, and
little/big endian?
I can only imagine it working with a carefully placed 1 bit. bit-0 of
the size on little endian, and bit-31 of the size on big endian. That
should only halve the address range (leaving 31 bits)... where did the
other 2 bits go?

Essentially it will use either the first or the last bit of the representation as discriminator. That bit is most likely "taken" from the length representation. Shifting and masking can easily account for it when computing length of large strings.

I also hope this only affects slices of chars? It will ignore this
behaviour for anything other than char arrays right?

It works for any arrays of sufficiently small immutable data type (e.g. immutable(byte)[]), but the most advantage is reaped for string.


Andrei

Reply via email to