On Fri, 19 Dec 2014 12:20:34 +
bearophile via Digitalmars-d-learn
wrote:
> anon:
>
> > Changed to
> > return data.map!(n => foo2(data, i + 1,
> > max)).cache.joiner.array;
> > then it produced the same result as array version.
> > `map.cache.join` resulted in 597871.
>
> This is close
anon:
Changed to
return data.map!(n => foo2(data, i + 1,
max)).cache.joiner.array;
then it produced the same result as array version.
`map.cache.join` resulted in 597871.
This is close to tell what the cause is :-)
Bye,
bearophile
On Fri, 19 Dec 2014 10:41:03 +
bearophile via Digitalmars-d-learn
wrote:
> Can you tell why? :-)
'cause lazy ranges can't be optimised in compile time? ;-)
signature.asc
Description: PGP signature
On Friday, 19 December 2014 at 10:41:04 UTC, bearophile wrote:
A case where the usage of ranges (UFCS chains) leads to very
bad performance:
import std.stdio: writeln;
import std.algorithm: map, join;
uint count1, count2;
const(int)[] foo1(in int[] data, in int i, in int max) {
count1++;
aldanor:
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?
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(r
On Friday, 19 December 2014 at 10:41:04 UTC, bearophile wrote:
A case where the usage of ranges (UFCS chains) leads to very
bad performance:
import std.stdio: writeln;
import std.algorithm: map, join;
uint count1, count2;
const(int)[] foo1(in int[] data, in int i, in int max) {
count1++;
A case where the usage of ranges (UFCS chains) leads to very bad
performance:
import std.stdio: writeln;
import std.algorithm: map, join;
uint count1, count2;
const(int)[] foo1(in int[] data, in int i, in int max) {
count1++;
if (i < max) {
typeof(return) result;
fore