Use common sub-expression more (r=self).

This commit is contained in:
Brendan Eich 2011-07-05 12:36:54 -07:00
parent b223802f5f
commit 40fbf4f25a

View File

@ -2519,19 +2519,18 @@ obj_create(JSContext *cx, uintN argc, Value *vp)
return JS_FALSE; return JS_FALSE;
} }
if (JSObject *proto = v.toObjectOrNull()) { JSObject *proto = v.toObjectOrNull();
if (proto->isXML()) { if (proto && proto->isXML()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XML_PROTO_FORBIDDEN); JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XML_PROTO_FORBIDDEN);
return false; return false;
}
} }
/* /*
* Use the callee's global as the parent of the new object to avoid dynamic * Use the callee's global as the parent of the new object to avoid dynamic
* scoping (i.e., using the caller's global). * scoping (i.e., using the caller's global).
*/ */
JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_ObjectClass, v.toObjectOrNull(), JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_ObjectClass, proto,
vp->toObject().getGlobal()); vp->toObject().getGlobal());
if (!obj) if (!obj)
return JS_FALSE; return JS_FALSE;
vp->setObject(*obj); /* Root and prepare for eventual return. */ vp->setObject(*obj); /* Root and prepare for eventual return. */