elm-community / dict-extra

A library with extra functions for the dictionary type in elm core.

Home Page:http://package.elm-lang.org/packages/elm-community/dict-extra/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance issue with groupBy

jvoigtlaender opened this issue · comments

In a call groupBy keyfn list, with the current implementation, the function keyfn will be applied potentially many times to each element of list, though one time should be enough. Depending on how expensive keyfn is to compute, this can be very bad.

The situation is like https://github.com/elm-lang/core/issues/485, and the solution would also be similar to there, i.e., first making a pass through the input list and pairing each element with its keyfn-image.

As a separate note: There was some discussion elsewhere, elm-community/elm-list-extra#38 (comment), whether this function should actually live in what is now https://github.com/elm-community/list-extra.