On Friday, 29 November 2019 at 15:54:13 UTC, realhet wrote:
On Friday, 29 November 2019 at 15:49:24 UTC, Paul Backus wrote:
It's actually a much simpler reason: filter calls .front twice for each element in its input (once to check if the value satisfies the predicate, and then again to return the value if it does), and the range returned by map doesn't save the value of .front between calls, so it has to re-compute it each time by calling the transform function.

This makes it clear.

In my case a cache which can access all the previous elements would be a too big thing, so I will do the filtering in a later stage manually. But most importantly, now I know what's going on, Thank You!

The "cache" wrapper only caches one element at a time. The cached value is discarded after each call to .popFront.

Reply via email to