Small Buffer Optimization for string and friends

Manu turkeyman at gmail.com
Sun Apr 8 02:54:44 PDT 2012


On 8 April 2012 12:46, Vladimir Panteleev <vladimir at thecybershadow.net>wrote:

> On Sunday, 8 April 2012 at 05:56:36 UTC, Andrei Alexandrescu wrote:
>
>> Walter and I discussed today about using the small string optimization in
>> string and other arrays of immutable small objects.
>>
>> On 64 bit machines, string occupies 16 bytes. We could use the first byte
>> as discriminator, which means that all strings under 16 chars need no
>> memory allocation at all.
>>
>
> Don't use the first byte. Use the last byte.
>
> The last byte is the highest-order byte of the length. Limiting arrays to
> 18.37 exabytes, as opposed to 18.45 exabytes, is a much nicer limitation
> than making assumptions about the memory layout.
>

What is the plan for 32bit?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120408/536aa8f2/attachment-0001.html>


More information about the Digitalmars-d mailing list