mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 799122 - Eagerly allocate dense elements for small arrays. r=luke
This commit is contained in:
parent
ef60a1c7b9
commit
b1e1601055
@ -2788,7 +2788,16 @@ js_Array(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
}
|
||||
|
||||
RootedObject obj(cx, NewDenseUnallocatedArray(cx, length));
|
||||
/*
|
||||
* Allocate dense elements eagerly for small arrays, to avoid reallocating
|
||||
* elements when filling the array.
|
||||
*/
|
||||
static const uint32_t ArrayEagerAllocationMaxLength = 2048;
|
||||
|
||||
RootedObject obj(cx);
|
||||
obj = (length <= ArrayEagerAllocationMaxLength)
|
||||
? NewDenseAllocatedArray(cx, length)
|
||||
: NewDenseUnallocatedArray(cx, length);
|
||||
if (!obj)
|
||||
return false;
|
||||
Rooted<ArrayObject*> arr(cx, &obj->as<ArrayObject>());
|
||||
|
Loading…
Reference in New Issue
Block a user