terezka / elm-charts

Create SVG charts in Elm.
https://www.elm-charts.org
BSD 3-Clause "New" or "Revised" License
736 stars 67 forks source link

Make functions tail-call recursive #100

Open jfmengels opened 3 years ago

jfmengels commented 3 years ago

2 changes here, both making some functions tail-call recursive.

For monotonePart, the |> prevented the optimization from happening.

For gatherWith, it's the same issue but because of <|. I made the same fix in elm-community/list-extra (https://github.com/elm-community/list-extra/commit/2d0eb640453313e8e1efc156a29ac68aecb21008#diff-97b2cb39788ae3d6877530635d216e6cd361006507af40173e5affcb5f095331)

I found this using using the [NoUnoptimizedRecursion](https://package.elm-lang.org/packages/jfmengels/elm-review-performance/latest/NoUnoptimizedRecursion] elm-review rule, which you can try out by running the following command:

elm-review --template jfmengels/elm-review-performance/example --rules NoUnoptimizedRecursion

There are some more to be fixed, but they're not as trivial, and the performance benefits will have to be evaluated.

PS: Running the tests doesn't work. The elm-explorations/test dependency is missing, and I think some others too, but I am not sure which one. NoRedInk/elm-plot-rouge?

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/terezka/elm-charts/ErYmhHzFgZw8K3XkFRVsuSpqBBA6
✅ Preview: https://elm-charts-git-fork-jfmengels-make-functions-tco-terezka.vercel.app