forked from mirrors/0ad
Improve performance of ScriptInterface::CreateObject from b4626359f5 / D2080 by creating the JSAutoRequest struct only once instead of once per property.
Differential Revision: https://code.wildfiregames.com/D2127 Comments By: Vladislav This was SVN commit r22680.
This commit is contained in:
@@ -567,13 +567,13 @@ bool ScriptInterface::CallFunction_(JS::HandleValue val, const char* name, JS::H
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ScriptInterface::CreateObject(JS::MutableHandleValue objectValue) const
|
||||
bool ScriptInterface::CreateObject_(JS::MutableHandleObject object) const
|
||||
{
|
||||
JSContext* cx = GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
// JSAutoRequest is the responsibility of the caller
|
||||
|
||||
objectValue.setObjectOrNull(JS_NewPlainObject(cx));
|
||||
if (!objectValue.isObject())
|
||||
object.set(JS_NewPlainObject(GetContext()));
|
||||
|
||||
if (!object)
|
||||
throw PSERROR_Scripting_CreateObjectFailed();
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user