Re: [JS-internals] Growing arrays

2014-07-18 Thread Nicholas Nethercote
On Thu, Jul 17, 2014 at 1:35 AM, Jan de Mooij jandemo...@gmail.com wrote: ArrayObject::EagerAllocationMaxLength (currently 2048) determines when |new Array(length)| will eagerly allocate. Maybe if it's 2048 we could allocate a bit more than 10 elements.. Thanks! I've written a patch so that

Re: [JS-internals] Growing arrays

2014-07-18 Thread Nicholas Nethercote
On Thu, Jul 17, 2014 at 1:14 AM, Katelyn Gadd k...@luminance.org wrote: What happens if you combine 'new Array(length)' + 'array[length - 1] = default value'? That seems like it would produce the optimal behavior in all cases. Thanks for the suggestion! This does work for SpiderMonkey, at

Re: [JS-internals] Growing arrays

2014-07-18 Thread Igor Bukanov
Well, with Firefox 31 using Array(length).fill(0) to construct the the array could be the best solution as it preallocates the array in one go. On 18 July 2014 00:42, Nicholas Nethercote n.netherc...@gmail.com wrote: In this case, maybe not, but there are many similar cases where using a typed