Code layout for range-intensive D code
Peter Alexander
peter.alexander.au at gmail.com
Sun Jun 10 16:10:56 PDT 2012
On Sunday, 10 June 2012 at 21:49:14 UTC, ixid wrote:
> Having to append .array() all the time is rather annoying. I
> can't help but feel that there's a better solution than this.
> Are lazy Result methods really the default way of doing things?
> I'd rather have eager versions.
Problem with eager versions is that you end up doing multiple
memory allocations and passes when combining range manipulators.
e.g.
r.take(n).filter!(blah).map!(whatever).array()
Only allocates once, and is only one linear pass over the memory.
If they were all eager, 'take' would create a new array, then
'filter' would pass over that and create a new array, then 'map'
would pass over that and create yet another array. Not very
efficient.
More information about the Digitalmars-d
mailing list