Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add replacement for List.filterMap #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jfmengels
Copy link
Contributor

This is applying the same technique from other List optimizations and applying it to List.filterMap.

Benchmark can be found here.

Here are the improvements (all taken using eol2) for Chrome:

Screenshot from 2021-12-14 17-37-19

and for Firefox:
Screenshot from 2021-12-14 18-04-47

var end = tmp;
for (; xs.b; xs = xs.b) {
var m = f(xs.a);
if (!m.$) {
Copy link
Owner

Choose a reason for hiding this comment

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

Should this actually check for m.a? I'm assuming that every elm type has a $ 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check is not about the presence of the $ field, it's about whether the Maybe returned by the function is Nothing ($ = 1 IIRC) or Just ($ = 0).

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