Skip to content

Add replacement for List.all#65

Merged
mdgriffith merged 2 commits into
mdgriffith:masterfrom
jfmengels:list-all-replacement
Feb 6, 2022
Merged

Add replacement for List.all#65
mdgriffith merged 2 commits into
mdgriffith:masterfrom
jfmengels:list-all-replacement

Conversation

@jfmengels

@jfmengels jfmengels commented Nov 24, 2021

Copy link
Copy Markdown
Contributor

This makes List.all quite a lot faster. The problem is the original uses this implementation:

var $elm$core$List$all = F2(
	function (isOkay, list) {
		return !A2(
			$elm$core$List$any,
			A2($elm$core$Basics$composeL, $elm$core$Basics$not, isOkay),
			list);
	});

The composeL (or << in Elm) is actually not very performant (benchmark, results). We could also make the same change by transforming composeL/composeR calls by anonymous functions, but that's more work. I do plan to add that, at which point we can probably remove this replacement (EDIT: done in #73).

I benchmarked the change. This is after compilation with elm-optimize-level-2 v0.2.3:

Results on Chrome:
Screenshot from 2021-11-25 17-57-50

Results on Firefox:

Screenshot from 2021-11-25 17-57-15

I don't have a Safari readily available, but I'll try to get results later (work computer is a Mac, so I can get them later).

@jfmengels

Copy link
Copy Markdown
Contributor Author

I found a newer version, 4x faster than what I proposed earlier.

This is basically a re-implementation of the function, written almost just like List.any and that doesn't defer to it.

Screenshot from 2022-01-02 22-13-16

PedroHLC pushed a commit to PedroHLC/elm-gobrrrrr that referenced this pull request Jan 21, 2022
mdgriffith#65

Add replacement for List.all

Add even faster replacement for List.all
@mdgriffith mdgriffith merged commit 30b83c1 into mdgriffith:master Feb 6, 2022
@jfmengels jfmengels deleted the list-all-replacement branch February 6, 2022 15:48
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