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:
elexis
2019-08-17 03:30:07 +00:00
parent ba56191dc2
commit 742f361b2d
2 changed files with 31 additions and 18 deletions
+5 -5
View File
@@ -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;