array traversal
Stewart Gordon
smjg_1998 at yahoo.com
Wed Mar 28 12:18:45 PDT 2007
"Dan" <murpsoft at hotmail.com> wrote in message
news:euecda$16oq$1 at digitalmars.com...
> Stewart Gordon Wrote:
>
>> "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
>>> }
<snip>
> Hmm... let me think of how that looks in ASM. The first one
> is wrong, because you're only ptr++, it should be ptr +=
> OFFSET. Apart from that, you're right the first code looks
> mildly better in ASM.
No it isn't. The ++ operator (and similarly --, +, -, +=, -=) applied to a
pointer works in the units of the size of the data type it points to.
> Looping through by adding to the pointer instead of adding to
> the array index and performing a 'lea'.
>
> The good news is that D *should be* optimizing this out, and
> it ultimately only costs a half cycle which may either align
> or throw off the u/v pipes - something more important than 1/2
> a cycle.
What on earth is a u/v pipe?
Stewart.
More information about the Digitalmars-d
mailing list