elm-community / list-extra

Convenience functions for working with List.
http://package.elm-lang.org/packages/elm-community/list-extra/latest
MIT License
135 stars 58 forks source link

Make gatherWith tail-call optimized #147

Closed jfmengels closed 3 years ago

jfmengels commented 3 years ago

This makes gatherWith tail-call optimized. I haven't benchmarked it, but since there is no other significant change in this function, I can only imagine that the performance improved.

Note: I discovered this issue with https://package.elm-lang.org/packages/jfmengels/elm-review-performance/latest/

Chadtech commented 3 years ago

Awesome! I did a benchmark just to check. In small lists, the performance increase appears to be around 5%: https://ellie-app.com/dnMGv4hW5kza1

jfmengels commented 3 years ago

I need to get into the habit of benchmarking, thanks setting it up!

For posterity's sake, here is my benchmark results

Screenshot from 2021-06-05 23-14-03

So not as good as the 5% you're seeing, but definitely an improvement, and stack safety :+1: