The future of foreach

Hxal hxal at freenode.d.channel
Tue Dec 25 12:51:59 PST 2007


Don Clugston Wrote:
> I don't think that's the main reason. A more fundumental problem is that 
> requiring a call to opApply on each foreach iteration is a massive performance 
> hit. This is a problem even in a normal use of foreach. Andrei is currently 
> trying to come up with a solution.

A dedicated optimization pass for functions taking delegates that is able to inline
them for delegates known at compile time would be nice. Especially if it worked
for nested delegates such as those used in iterator adaptors.
But that might be hard to do with virtual opApply in classes.

(PS. opApply gets called once, its delegate argument gets called for each iteration)




More information about the Digitalmars-d mailing list