Bug 1056795 - Optimize ArrayPushDense. r=bhackett

This commit is contained in:
Jan de Mooij 2014-08-21 18:51:40 +02:00
parent bc56909bfa
commit 7fb3a284dc

View File

@ -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();