diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-01 20:05:57 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-02 08:01:00 (GMT) |
commit | 0b5a81dd9aa153f6cd3a3929ee7ed82ca48f45a5 (patch) | |
tree | 872442f35c338ec989bcf60f8691d9c0cda2f420 /src/script | |
parent | 7578f43d0f1358b2ed52b3a5d2b853f26e63aec0 (diff) | |
download | Qt-0b5a81dd9aa153f6cd3a3929ee7ed82ca48f45a5.zip Qt-0b5a81dd9aa153f6cd3a3929ee7ed82ca48f45a5.tar.gz Qt-0b5a81dd9aa153f6cd3a3929ee7ed82ca48f45a5.tar.bz2 |
Optimize QScriptClass
Do not convert JSC::Identifier to QString to convert it later to
JSC::Identivier again
Reviewed-by: Kent Hansen
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 4 | ||||
-rw-r--r-- | src/script/api/qscriptengine_p.h | 10 | ||||
-rw-r--r-- | src/script/api/qscriptstring.cpp | 10 | ||||
-rw-r--r-- | src/script/api/qscriptstring.h | 1 | ||||
-rw-r--r-- | src/script/api/qscriptstring_p.h | 2 | ||||
-rw-r--r-- | src/script/bridge/qscriptclassobject.cpp | 12 |
6 files changed, 16 insertions, 23 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index d467250..3ffc9c5 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -3622,9 +3622,7 @@ QScriptEngineAgent *QScriptEngine::agent() const QScriptString QScriptEngine::toStringHandle(const QString &str) { Q_D(QScriptEngine); - QScriptString ss; - QScriptStringPrivate::init(ss, this, JSC::Identifier(d->currentFrame, str)); - return ss; + return d->scriptStringFromJSCIdentifier(JSC::Identifier(d->currentFrame, str)); } /*! diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index f06f717..f8eee87 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -58,6 +58,7 @@ #include <QtCore/qhash.h> #include <QtCore/qset.h> #include "qscriptvalue_p.h" +#include "qscriptstring_p.h" #include "RefPtr.h" #include "Structure.h" @@ -122,6 +123,7 @@ public: inline QScriptValue scriptValueFromJSCValue(JSC::JSValue value); inline JSC::JSValue scriptValueToJSCValue(const QScriptValue &value); + inline QScriptString scriptStringFromJSCIdentifier(const JSC::Identifier &id); QScriptValue scriptValueFromVariant(const QVariant &value); QVariant scriptValueToVariant(const QScriptValue &value, int targetType); @@ -362,6 +364,14 @@ inline QScriptValue QScriptValuePrivate::property(const QString &name, int resol return property(JSC::Identifier(exec, name), resolveMode); } +inline QScriptString QScriptEnginePrivate::scriptStringFromJSCIdentifier(const JSC::Identifier &id) +{ + QScriptString q; + q.d_ptr = new QScriptStringPrivate(q_func(), id); + return q; +} + + QT_END_NAMESPACE #endif diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp index 58a7c2b..6de1d88 100644 --- a/src/script/api/qscriptstring.cpp +++ b/src/script/api/qscriptstring.cpp @@ -86,16 +86,6 @@ QScriptStringPrivate::~QScriptStringPrivate() } /*! - \internal -*/ -void QScriptStringPrivate::init(QScriptString &q, QScriptEngine *engine, - const JSC::Identifier &value) -{ - Q_ASSERT(!q.isValid()); - q.d_ptr = new QScriptStringPrivate(engine, value); -} - -/*! Constructs an invalid QScriptString. */ QScriptString::QScriptString() diff --git a/src/script/api/qscriptstring.h b/src/script/api/qscriptstring.h index 30e6856..e6224a2 100644 --- a/src/script/api/qscriptstring.h +++ b/src/script/api/qscriptstring.h @@ -76,6 +76,7 @@ public: private: QExplicitlySharedDataPointer<QScriptStringPrivate> d_ptr; friend class QScriptValue; + friend class QScriptEnginePrivate; Q_DECLARE_PRIVATE(QScriptString) }; diff --git a/src/script/api/qscriptstring_p.h b/src/script/api/qscriptstring_p.h index 8f76648..bba4b58 100644 --- a/src/script/api/qscriptstring_p.h +++ b/src/script/api/qscriptstring_p.h @@ -72,8 +72,6 @@ public: QScriptStringPrivate(QScriptEngine *engine, const JSC::Identifier &id); ~QScriptStringPrivate(); - static void init(QScriptString &q, QScriptEngine *engine, const JSC::Identifier &id); - QBasicAtomicInt ref; #ifndef QT_NO_QOBJECT QPointer<QScriptEngine> engine; diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index c8633ab..fcd0124 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -97,8 +97,7 @@ bool ClassObjectDelegate::getOwnPropertySlot(QScriptObject* object, QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesReadAccess, &id); @@ -116,8 +115,7 @@ void ClassObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec, { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesWriteAccess, &id); @@ -135,8 +133,7 @@ bool ClassObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState * // ### avoid duplication of put() QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesWriteAccess, &id); @@ -155,8 +152,7 @@ bool ClassObjectDelegate::getPropertyAttributes(const QScriptObject* object, JSC { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); - QString name(propertyName.ustring()); - QScriptString scriptName = QScriptEnginePrivate::get(engine)->toStringHandle(name); + QScriptString scriptName = engine->scriptStringFromJSCIdentifier(propertyName); uint id = 0; QScriptClass::QueryFlags flags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesReadAccess, &id); |