purescript-lists icon indicating copy to clipboard operation
purescript-lists copied to clipboard

Why does lazy list foldr reverse into a temporary lazy list?

Open FranklinChen opened this issue 3 years ago • 1 comments

I get why https://github.com/purescript/purescript-lists/blob/v6.0.0/src/Data/List/Lazy/Types.purs#L121 does what it does with reverse, but it seems to me there is no reason to create a brand new temporary lazy list just to consume it left to right. How about pushing elements left to right into a temporary JavaScript array and then going right to left in that?

FranklinChen avatar Mar 09 '21 18:03 FranklinChen

No objections to optimizing by using a temporary JS array. I think the existing version was chosen just to keep the code concise at the cost of performance.

Another issue discussing improving reverse performance is #185

milesfrain avatar Mar 10 '21 02:03 milesfrain