Open dead-claudia opened 4 years ago
- For polyfills, using the obvious
Array.from(set)
rather than a parallel array.
"a parallel array" means [...new Set([])]
?
I was referring to converting the set into an array at the end rather than building an array alongside the set.
@isiahmeadows Not sure whether they would have perf difference...
It may, considering CPU pipelines and such - with a specialized data structure, it becomes effectively just a copy, and CPUs like that. They can also allocate only the memory needed for the returned result in one single step as opposed to potentially multiple allocations in the loop, thus wasting less memory and reducing the overhead in the loop itself.
It may also slower, especially in embed js engines. :-P
Part of why I said "should consider" and not that it's an outright recommendation like using hash tables for Map
- I know embedded and server engines don't work the same way and have two different sets of needs, and space constraints may very well preclude using those recommendations. (For BigInts, there's been some recent chatter in v8-dev of potentially creating a split implementation for multiplication and division of large BigInts to cater to both embedded and high-performance needs, and factoring it out into a standalone library for other runtimes to use. So there's precedent.)
This is more an FYI than a specific feature request. For ideal performance, implementations should consider the following:
Array.from(set)
rather than a parallel array.