Array append performance

bearophile bearophileHUGS at lycos.com
Wed Aug 27 08:20:55 PDT 2008


Sean Kelly:
> Why not just change that to this instead:
> 
> switch(i) {
>     case 8: a[7] = b[7];
>     case 7: a[6] = b[6];
>     case 6: a[5] = b[5];
>     case 5: a[4] = b[4];
>     case 4: a[3] = b[3];
>     case 3: a[2] = b[2];
>     case 1: a[0] = b[0];
>     case 0: break;
>     default: memcpy( a.ptr, b.ptr, a.length * DataType.sizeof );
> }
> 
> The Range stuff is cool and all, but not really necessary :-)

I have benchmarked many alternative versions, your one too, but mine is significantly faster than your one on the DMD I am using. Don't ask me why.

You can find the Range!([start,] stop[, step]) in my libs, of course ;-)

Bye,
bearophile



More information about the Digitalmars-d mailing list