Change representation of dynamic arrays?
0ffh
spam at frankhirsch.net
Fri Oct 19 22:37:04 PDT 2007
Daniel Keep wrote:
> You say you've measured the performance of loops using this, but what
> about slicing code? I know that I use a lot of [lower..$-something]
> style code; how much slower does this become? Once I'm not so busy, I
> might try to work out the proportion of foreach to $ slicing in my code. :P
I guess we go from changing one pointer and a size_t to changing two
pointers, I can't see a lot of space for that being slower than now.
Consider:
wchar[] str="this is a test";
int s=10; // slice start
int e=14; // slice end
tst=s[s..e];
Old array:
tst.ptr=str.ptr+s*wchar.sizeof;
tst.len=e-s;
New array:
tst.start=str.start+s*wchar.sizeof;
tst.end=str.start+e*wchar.sizeof;
Regards, Frank
More information about the Digitalmars-d
mailing list