summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-24 11:39:37 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-24 11:41:12 (GMT)
commitc354b3d4d27be3fdefc09b73c5b6965c8527e2cd (patch)
tree75bb202ca0386b6131e625052d7dd775f95a11e7 /src/script
parent95567be17fd5a6e0be95bc3312b3e526c4130ebf (diff)
downloadQt-c354b3d4d27be3fdefc09b73c5b6965c8527e2cd.zip
Qt-c354b3d4d27be3fdefc09b73c5b6965c8527e2cd.tar.gz
Qt-c354b3d4d27be3fdefc09b73c5b6965c8527e2cd.tar.bz2
avoid calling QScriptValue::isFunction() inside call() and construct()
Avoid calling virtual function JSC::JSValue::get{Call,Construct}Data() twice. Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/qscriptvalue.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 922b068..a9c07a7 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -1928,7 +1928,12 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
const QScriptValueList &args)
{
Q_D(const QScriptValue);
- if (!isFunction())
+ if (!d || !d->isJSC())
+ return QScriptValue();
+ JSC::JSValue callee = d->jscValue;
+ JSC::CallData callData;
+ JSC::CallType callType = callee.getCallData(callData);
+ if (callType == JSC::CallTypeNone)
return QScriptValue();
if (thisObject.engine() && (thisObject.engine() != engine())) {
@@ -1960,9 +1965,6 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
}
JSC::ArgList jscArgs(argsVector.data(), argsVector.size());
- JSC::JSValue callee = d->jscValue;
- JSC::CallData callData;
- JSC::CallType callType = callee.getCallData(callData);
JSC::JSValue savedException;
QScriptValuePrivate::saveException(exec, &savedException);
JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, jscArgs);
@@ -2001,7 +2003,12 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
const QScriptValue &arguments)
{
Q_D(QScriptValue);
- if (!isFunction())
+ if (!d || !d->isJSC())
+ return QScriptValue();
+ JSC::JSValue callee = d->jscValue;
+ JSC::CallData callData;
+ JSC::CallType callType = callee.getCallData(callData);
+ if (callType == JSC::CallTypeNone)
return QScriptValue();
if (thisObject.engine() && (thisObject.engine() != engine())) {
@@ -2038,9 +2045,6 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
}
}
- JSC::JSValue callee = d->jscValue;
- JSC::CallData callData;
- JSC::CallType callType = callee.getCallData(callData);
JSC::JSValue savedException;
QScriptValuePrivate::saveException(exec, &savedException);
JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, applyArgs);
@@ -2073,8 +2077,14 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
QScriptValue QScriptValue::construct(const QScriptValueList &args)
{
Q_D(const QScriptValue);
- if (!isFunction())
+ if (!d || !d->isJSC())
return QScriptValue();
+ JSC::JSValue callee = d->jscValue;
+ JSC::ConstructData constructData;
+ JSC::ConstructType constructType = callee.getConstructData(constructData);
+ if (constructType == JSC::ConstructTypeNone)
+ return QScriptValue();
+
JSC::ExecState *exec = d->engine->currentFrame;
QVarLengthArray<JSC::JSValue, 8> argsVector(args.size());
@@ -2087,9 +2097,6 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args)
JSC::ArgList jscArgs(argsVector.data(), argsVector.size());
- JSC::JSValue callee = d->jscValue;
- JSC::ConstructData constructData;
- JSC::ConstructType constructType = callee.getConstructData(constructData);
JSC::JSValue savedException;
QScriptValuePrivate::saveException(exec, &savedException);
JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, jscArgs);
@@ -2119,8 +2126,14 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args)
QScriptValue QScriptValue::construct(const QScriptValue &arguments)
{
Q_D(QScriptValue);
- if (!isFunction())
+ if (!d || !d->isJSC())
return QScriptValue();
+ JSC::JSValue callee = d->jscValue;
+ JSC::ConstructData constructData;
+ JSC::ConstructType constructType = callee.getConstructData(constructData);
+ if (constructType == JSC::ConstructTypeNone)
+ return QScriptValue();
+
JSC::ExecState *exec = d->engine->currentFrame;
JSC::JSValue array = d->engine->scriptValueToJSCValue(arguments);
@@ -2143,9 +2156,6 @@ QScriptValue QScriptValue::construct(const QScriptValue &arguments)
}
}
- JSC::JSValue callee = d->jscValue;
- JSC::ConstructData constructData;
- JSC::ConstructType constructType = callee.getConstructData(constructData);
JSC::JSValue savedException;
QScriptValuePrivate::saveException(exec, &savedException);
JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, applyArgs);