Skip to content

Conversation

@mbostock
Copy link
Member

Continuation of #863: if we can use array.map or array.slice instead of Array.from, do so because it’s faster. Supposedly. I didn’t actually check so this could be premature optimization. But this was also relatively easy, so… 🤷.

@mbostock mbostock requested a review from Fil May 30, 2022 15:32
@Fil
Copy link
Contributor

Fil commented May 30, 2022

I tested a little bit. In Chrome this seems indifferent, but in Safari and FF it's 2x faster—and even 10x faster for typed arrays in Safari… (Also, it makes the code a bit nicer to read.)

One question though: slice is never called with the type parameter?

@mbostock
Copy link
Member Author

One question though: slice is never called with the type parameter?

Sure, but I wanted symmetry with map.

@mbostock mbostock merged commit 48115f9 into main May 31, 2022
@mbostock mbostock deleted the mbostock/map-from branch May 31, 2022 01:21
@Fil Fil mentioned this pull request Aug 10, 2022
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.

3 participants