mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1056795 - Optimize ArrayPushDense. r=bhackett
This commit is contained in:
parent
bc56909bfa
commit
7fb3a284dc
@ -401,6 +401,21 @@ bool
|
||||
ArrayPushDense(JSContext *cx, HandleObject obj, HandleValue v, uint32_t *length)
|
||||
{
|
||||
JS_ASSERT(obj->is<ArrayObject>());
|
||||
JS_ASSERT(obj->as<ArrayObject>().lengthIsWritable());
|
||||
JS_ASSERT(!ObjectMayHaveExtraIndexedProperties(obj));
|
||||
|
||||
uint32_t idx = obj->as<ArrayObject>().length();
|
||||
JSObject::EnsureDenseResult result = obj->ensureDenseElements(cx, idx, 1);
|
||||
if (result == JSObject::ED_FAILED)
|
||||
return false;
|
||||
|
||||
if (result == JSObject::ED_OK) {
|
||||
obj->setDenseElement(idx, v);
|
||||
MOZ_ASSERT(idx < INT32_MAX);
|
||||
*length = idx + 1;
|
||||
obj->as<ArrayObject>().setLengthInt32(*length);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS::AutoValueArray<3> argv(cx);
|
||||
argv[0].setUndefined();
|
||||
|
Loading…
Reference in New Issue
Block a user