From 40fbf4f25a02e9713337bd9abb44ad89e93a0308 Mon Sep 17 00:00:00 2001 From: Brendan Eich Date: Tue, 5 Jul 2011 12:36:54 -0700 Subject: [PATCH] Use common sub-expression more (r=self). --- js/src/jsobj.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 01ca033e5f5..b4d03df2e32 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -2519,19 +2519,18 @@ obj_create(JSContext *cx, uintN argc, Value *vp) return JS_FALSE; } - if (JSObject *proto = v.toObjectOrNull()) { - if (proto->isXML()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XML_PROTO_FORBIDDEN); - return false; - } + JSObject *proto = v.toObjectOrNull(); + if (proto && proto->isXML()) { + JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XML_PROTO_FORBIDDEN); + return false; } /* * Use the callee's global as the parent of the new object to avoid dynamic * scoping (i.e., using the caller's global). */ - JSObject *obj = NewNonFunction(cx, &js_ObjectClass, v.toObjectOrNull(), - vp->toObject().getGlobal()); + JSObject *obj = NewNonFunction(cx, &js_ObjectClass, proto, + vp->toObject().getGlobal()); if (!obj) return JS_FALSE; vp->setObject(*obj); /* Root and prepare for eventual return. */