array traversal

Stewart Gordon smjg_1998 at yahoo.com
Wed Mar 28 07:12:21 PDT 2007


"BCS" <ao at pathlink.com> wrote in message 
news:ce0a3343870c8c939107e7e1a1e at news.digitalmars.com...
<snip>
> I think that options he is taking about are these
> for(T* ptr = &start; ptr !is &stop; ptr++)
> {
>  T value = *ptr
> }
>
> vs.
>
> for(int i = 0; i< length; i++)
> {
>   T value = ptr[i];
> }
>
> only the second ever uses a multiplication

And even then not necessarily - some compilers may optimise one form to the 
other.

Stewart. 




More information about the Digitalmars-d mailing list