freemail icon indicating copy to clipboard operation
freemail copied to clipboard

use Set.has instead of Array.indexOf

Open d1manson opened this issue 5 years ago • 0 comments

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

d1manson avatar May 26 '20 18:05 d1manson