Avoid useless function check in executeFunctionWithOwner and useless js parameter construction in websocket

This commit is contained in:
pandamicro
2017-09-04 13:46:37 +08:00
parent 97b52f38cb
commit 0b057318a4
2 changed files with 96 additions and 84 deletions
@@ -1670,24 +1670,25 @@ bool ScriptingCore::executeFunctionWithOwner(JS::HandleValue owner, const char *
JS::RootedValue ownerval(cx, owner);
JS::RootedObject obj(cx);
if (ownerval.isObject())
obj = ownerval.toObjectOrNull();
do
{
if (JS_HasProperty(cx, obj, name, &hasFunc) && hasFunc) {
if (!JS_GetProperty(cx, obj, name, &funcVal)) {
break;
obj = ownerval.toObjectOrNull();
do
{
if (JS_HasProperty(cx, obj, name, &hasFunc) && hasFunc) {
if (!JS_GetProperty(cx, obj, name, &funcVal)) {
break;
}
if (funcVal.isNullOrUndefined()) {
break;
}
bRet = JS_CallFunctionValue(cx, obj, funcVal, args, retVal);
if (JS_IsExceptionPending(cx)) {
handlePendingException(cx);
}
}
if (funcVal.isNullOrUndefined()) {
break;
}
bRet = JS_CallFunctionValue(cx, obj, funcVal, args, retVal);
if (JS_IsExceptionPending(cx)) {
handlePendingException(cx);
}
}
}while(0);
} while(0);
}
return bRet;
}