Interesting Memory Optimization

Kevin kevincox.ca at gmail.com
Thu Mar 15 19:16:18 PDT 2012


This is in no way D specific but say you have two constant strings.

const char[] a = "1234567890";
// and
const char[] b = "67890";

You could lay out the memory inside of one another. IE: if a.ptr = 1 
then b.ptr = 6.  I'm not sure if this has been done and I don't think it 
would apply very often but it would be kinda cool.

I thought of this because I wanted to pre-generate hex-representations 
of some numbers I realized I could use half the memory if I nested them. 
(At least I think it would be half).

Kevin.




More information about the Digitalmars-d mailing list