Speed up Array.shift, and Array.{pop,shift} on empty arrays, bug 692847. r=dvander
This commit is contained in:
@@ -2565,8 +2565,26 @@ js::array_pop(JSContext *cx, uintN argc, Value *vp)
|
||||
return array_pop_slowly(cx, obj, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_shift(JSContext *cx, uintN argc, Value *vp)
|
||||
#ifdef JS_METHODJIT
|
||||
void FASTCALL
|
||||
mjit::stubs::ArrayShift(VMFrame &f)
|
||||
{
|
||||
JSObject *obj = &f.regs.sp[-1].toObject();
|
||||
JS_ASSERT(obj->isDenseArray());
|
||||
JS_ASSERT(!js_PrototypeHasIndexedProperties(f.cx, obj));
|
||||
|
||||
/*
|
||||
* At this point the length and initialized length have already been
|
||||
* decremented and the result fetched, so just shift the array elements
|
||||
* themselves.
|
||||
*/
|
||||
uint32 initlen = obj->getDenseArrayInitializedLength();
|
||||
obj->moveDenseArrayElements(0, 1, initlen);
|
||||
}
|
||||
#endif /* JS_METHODJIT */
|
||||
|
||||
JSBool
|
||||
js::array_shift(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JSObject *obj = ToObject(cx, &vp[1]);
|
||||
if (!obj)
|
||||
|
||||
Reference in New Issue
Block a user