Skip to content

Add replacement for List.filterMap#75

Open
jfmengels wants to merge 1 commit into
mdgriffith:masterfrom
jfmengels:list-filtermap-replacement
Open

Add replacement for List.filterMap#75
jfmengels wants to merge 1 commit into
mdgriffith:masterfrom
jfmengels:list-filtermap-replacement

Conversation

@jfmengels

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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