for versus foreach
John Demme
me at teqdruid.com
Sat Apr 8 14:18:52 PDT 2006
kris wrote:
>
> With the x86-32 architecture, anything that prevents register-spills is
> a bonus for some types of code, and I found foreach to be a better
> choice in a number of cases. The potentially negative aspect is that
> foreach is based upon a callback mechanism, so if the loop-body cannot
> be "inlined" there will be a call/ret involved for each iteration.
> Whether or not that's significant is very much application specific.
>
I don't think foreach can ever be inlined in the operator overloading case
since opApply takes a delegate. DMD might be smarter than I though;
however, I've refactored delegate parameters into templated code for the
sole purpose of allowing functions to be inlined.
~John Demme
More information about the Digitalmars-d-learn
mailing list