Skip to content

use Set.has instead of Array.indexOf#68

Open
d1manson wants to merge 1 commit intowillwhite:masterfrom
d1manson:master
Open

use Set.has instead of Array.indexOf#68
d1manson wants to merge 1 commit intowillwhite:masterfrom
d1manson:master

Conversation

@d1manson
Copy link

Array.indexOf is O(n), but Set.has is O(1) ..or something similar. At any rate there's at least a 20x difference in performance given the size of the list here.

I made a jsperf to demonstrate this using 1/5 of the free emails.

https://jsperf.com/array-indexof-versus-set-has/1

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.

1 participant