indigo
indigo copied to clipboard
Performance(?): Remove `foldLeft` in frame processors
Needs be benchmarked!
I noticed a long time ago that using foldLeft
was noticeably slower than other approaches like tail recursion. Not sure why that should be the case given that js array impl is a tiny for loop and a var - perhaps I was looking at List or something? - but hence the need to benchmark.
Anyway, should that indeed turn out to be the case, the frame processor functions are using foldLeft's for event processing, which makes it easy to appreciate what's going on, but might be a quick performance win if swapped for another technique.
Note: Even if foldLeft itself turns out to be ok, there might still be a gain from using a tail rec function simply because we could roll the 3-4 maps and filters into a single step.