Skip to content

Conversation

@jfmengels
Copy link
Contributor

This improves the performance of the filter function.

The main change is that we don't call Maybe.map f, which removes some wrapping and unwrapping of the value. With it, we are in practice doing 2 pattern matching (one in this function and one in Maybe.map), plus wrapping the value in a Just inside the Maybe.map.

In this proposed version, these operations are removed compared to the original version.

Here is a benchmark: https://ellie-app.com/fCC677f4YLKa1

Screenshot 2021-10-20 at 13 23 29

(Note and if you're interested: This is similar-ish to the PR I made for Result.Extra.filter elm-community/result-extra#31 )

Copy link
Collaborator

@skyqrose skyqrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@skyqrose skyqrose merged commit 59a5ecb into elm-community:master Oct 28, 2021
@jfmengels jfmengels deleted the faster-filter branch November 6, 2021 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants