I'm catching up with the posts.

Joseph Wakeling:

> As for iteration, I don't know to what degree D's foreach() across
> arrays compares to for() commands in C++ -- I guess it should be pretty
> close in performance, no?

As you have seen from my benchmarks, when with dmd you use:
foreach (x; arr)
and x is longer than a word, then the loop is not as fast as it can be. When x 
is longer than a word it's often more efficient to use a ref, especially in the 
inner loop:
foreach (ref const(double) x; arr)
With the ldc compiler the different between using or not using a ref is zero, 
or some times using ref slows down the foreach a little.
I have not filed enhancement requests about this because I think it's useless.

Bye,
bearophile

Reply via email to