Loops versus ranges

aldanor via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 19 03:04:46 PST 2014


On Friday, 19 December 2014 at 10:57:47 UTC, aldanor wrote:
> Something about the loop in the first case not depending on n 
> and the compiler being able to figure it is out and only drop 
> into recursion once?
That's just a wild guess, but does it get transformed into 
something like this?

typeof(return) result;
typeof(return) tmp = foo1(data, i + 1, max);
foreach (immutable n; data)
     result ~= tmp;


More information about the Digitalmars-d-learn mailing list