@mathias Great talk. Thanks. Does a map on a packed HOLEY array return a PACKED or HOLEY?
e.g. Array(3).fill(1).map((_, i) => i) => [1,2,3] //HOLEY_ or _PACKED_
Array#map creates a new array of the needed length (see step 5 of https://tc39.github.io/ecma262/#sec-array.prototype.map …) similar to `new Array(length)`, so the result would be HOLEY.
-
-
Does this mean that I can't avoid HOLEY arrays because a PACKED array is converted to HOLEY upon map.
-
It’s not “converted” — `map` returns a new array. But yeah, if you use `map`, the result is always HOLEY.
- 7 more replies
New conversation -
-
-
Ok, so I built V8 from source. There seems to be little value in the array optimisations from v8. The moment I do anything interesting with an array, it becomes HOLEY_. It feels like .map, .reduce and esp .fill are opportunities for v8 to reclassify the elements kind
#jsconfau18pic.twitter.com/3qb5ax9TRz
-
Ok. I've dug deeper and the results are confusing. The spread operator combined with .push seems to be the simplest way back to a PACKED_ setup. While version 'h', when compared to 'g', 'i' and 'k', is bizarre.pic.twitter.com/wk6BhwC6Fg
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.