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 wrote:
> In this case, maybe not, but there are many similar cases where using
> a typed array is less feasibl
On Thu, Jul 17, 2014 at 1:14 AM, Katelyn Gadd wrote:
> What happens if you combine 'new Array(length)' + 'array[length - 1] =
> '? That seems like it would produce the optimal
> behavior in all cases.
Thanks for the suggestion! This does work for SpiderMonkey, at least
in some case, but it might
On Thu, Jul 17, 2014 at 1:35 AM, Jan de Mooij 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 it allocates min
On 07/16/2014 11:40 PM, Nicholas Nethercote wrote:
> On a related note: ObjectElements::VALUES_PER_HEADER is 2. Is this
> because 2 * sizeof(HeapSlot) is 16 bytes, which is equal to
> sizeof(ObjectElements)?
Yes.
> Nick
>
> On Wed, Jul 16, 2014 at 11:34 PM, Nicholas Nethercote
> wrote:
>> On W
On 2014-07-17, 4:35 AM, Jan de Mooij wrote:
On Thu, Jul 17, 2014 at 8:34 AM, Nicholas Nethercote
wrote:
Oh wait. It depends on the value of |length|. If it's 2050 or less,
then the right-sized array is allocated immediately. Otherwise, it
allocates 10 elements and then does the doubling thing.
On 07/16/2014 11:08 PM, Nicholas Nethercote wrote:
So then I tried reverting that change and inserting this line just
before the loop:
array[length - 1] = 0;
And now it avoids the doubling allocations -- the array elements are
allocated once, at the right size. But it feels dirty, and I don'
I would expect that for some values of length it would be deemed "too
sparse" and no longer treated as a single underlying vector.
On Thursday, July 17, 2014, Katelyn Gadd wrote:
> What happens if you combine 'new Array(length)' + 'array[length - 1] =
> '? That seems like it would produce the op
On Thu, Jul 17, 2014 at 8:34 AM, Nicholas Nethercote
wrote:
> Oh wait. It depends on the value of |length|. If it's 2050 or less,
> then the right-sized array is allocated immediately. Otherwise, it
> allocates 10 elements and then does the doubling thing. I guess
> there's a limit to how much we'
What happens if you combine 'new Array(length)' + 'array[length - 1] =
'? That seems like it would produce the optimal
behavior in all cases.
On Wed, Jul 16, 2014 at 11:40 PM, Nicholas Nethercote
wrote:
> On a related note: ObjectElements::VALUES_PER_HEADER is 2. Is this
> because 2 * sizeof(Heap
9 matches
Mail list logo