<div class="gmail_quote">On 8 April 2012 12:46, Vladimir Panteleev <span dir="ltr"><<a href="mailto:vladimir@thecybershadow.net">vladimir@thecybershadow.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sunday, 8 April 2012 at 05:56:36 UTC, Andrei Alexandrescu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Walter and I discussed today about using the small string optimization in string and other arrays of immutable small objects.<br>
<br>
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.<br>
</blockquote>
<br></div>
Don't use the first byte. Use the last byte.<br>
<br>
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.<br></blockquote><div><br>
</div><div>What is the plan for 32bit?</div></div><br>