Testing array ptr for offset 0...

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 27 03:29:38 PDT 2016


On Friday, 27 May 2016 at 09:18:47 UTC, Marc Schütz wrote:
> You can do that with arrays, too, without causing allocations:
>
>     assert(slice.length < static_array.length);
>     slice = slice.ptr[0 .. slice.length+1];
>
> Of course that's unsafe, but your pointer magic certainly is, 
> too.

  Initial impressions suggest it's actually slower. The multiple 
dereferences to do it since it's a 2d array...


More information about the Digitalmars-d-learn mailing list