Remove leftover use of js_NewArrayObjectWithCapacity (follow-up for bug 581264).

This commit is contained in:
Andreas Gal 2010-07-23 16:05:36 -07:00
parent c9bde05bd6
commit 2588647cb3

View File

@ -5038,17 +5038,17 @@ FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp
size_t len = fninfo->mArgTypes.length();
// Prepare a new array.
jsval* vec;
JSObject* argTypes =
js_NewArrayObjectWithCapacity(cx, len, &vec);
if (!argTypes)
Array<jsval, 16> vec;
if (!vec.resize(len))
return JS_FALSE;
js::AutoObjectRooter argsroot(cx, argTypes);
JS_ASSERT(len == 0 || vec);
for (size_t i = 0; i < len; ++i)
vec[i] = OBJECT_TO_JSVAL(fninfo->mArgTypes[i]);
JSObject* argTypes = JS_NewArrayObject(cx, len, vec.begin());
if (!argTypes)
return JS_FALSE;
// Seal and cache it.
if (!JS_SealObject(cx, argTypes, JS_FALSE) ||
!JS_SetReservedSlot(cx, obj, SLOT_ARGS_T, OBJECT_TO_JSVAL(argTypes)))