"Walter Bright" <newshou...@digitalmars.com> wrote in message news:i98frv$1dm...@digitalmars.com... > bearophile wrote: >> Nick Sabalausky: >> >>> Then you're wasting cycles every iteration (by doing an extra addition >>> and maybe an extra shift or even multiplication depending on T: Ie, >>> (cast(ubyte*)myArray.ptr) + i * T.sizeof). That was a pretty common >>> inner-loop optimization back in my C days. >> >> With D sometimes array-based code is faster than pointer-based. With LDC >> they are usually equally efficient. > > ??? This makes no sense. > > The (ptr+i*T.sizeof) is an addressing mode on the x86, and comes at ZERO > cost.
As long as T.sizeof is either 1, 2, 4, or 8 bytes.