From 36d365458d54c6168c8003f7348e932e3a4ffc2c Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 16:47:04 +0200 Subject: Inline internal QtScript object delegate functions Makes QScriptValue::scriptClass() 20% faster. Reviewed-by: Olivier Goffart --- src/script/bridge/qscriptclassobject.cpp | 11 ----------- src/script/bridge/qscriptclassobject_p.h | 15 +++++++++++++-- src/script/bridge/qscriptobject.cpp | 16 ---------------- src/script/bridge/qscriptobject_p.h | 20 ++++++++++++++++++-- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index 0d88532..1dde98b 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -70,17 +70,6 @@ ClassObjectDelegate::~ClassObjectDelegate() { } -QScriptClass *ClassObjectDelegate::scriptClass() const -{ - return m_scriptClass; -} - -void ClassObjectDelegate::setScriptClass(QScriptClass *scriptClass) -{ - Q_ASSERT(scriptClass != 0); - m_scriptClass = scriptClass; -} - QScriptObjectDelegate::Type ClassObjectDelegate::type() const { return ClassObject; diff --git a/src/script/bridge/qscriptclassobject_p.h b/src/script/bridge/qscriptclassobject_p.h index f5cce76..9b34244 100644 --- a/src/script/bridge/qscriptclassobject_p.h +++ b/src/script/bridge/qscriptclassobject_p.h @@ -70,8 +70,8 @@ public: ClassObjectDelegate(QScriptClass *scriptClass); ~ClassObjectDelegate(); - QScriptClass *scriptClass() const; - void setScriptClass(QScriptClass *scriptClass); + inline QScriptClass *scriptClass() const; + inline void setScriptClass(QScriptClass *scriptClass); virtual Type type() const; @@ -105,6 +105,17 @@ private: QScriptClass *m_scriptClass; }; +inline QScriptClass *ClassObjectDelegate::scriptClass() const +{ + return m_scriptClass; +} + +inline void ClassObjectDelegate::setScriptClass(QScriptClass *scriptClass) +{ + Q_ASSERT(scriptClass != 0); + m_scriptClass = scriptClass; +} + } // namespace QScript QT_END_NAMESPACE diff --git a/src/script/bridge/qscriptobject.cpp b/src/script/bridge/qscriptobject.cpp index 55644fe..4808c7c 100644 --- a/src/script/bridge/qscriptobject.cpp +++ b/src/script/bridge/qscriptobject.cpp @@ -84,22 +84,6 @@ void QScriptObject::setData(JSC::JSValue data) d->data = data; } -QScriptObjectDelegate *QScriptObject::delegate() const -{ - if (!d) - return 0; - return d->delegate; -} - -void QScriptObject::setDelegate(QScriptObjectDelegate *delegate) -{ - if (!d) - d = new Data(); - else - delete d->delegate; - d->delegate = delegate; -} - bool QScriptObject::getOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) diff --git a/src/script/bridge/qscriptobject_p.h b/src/script/bridge/qscriptobject_p.h index c1cee31..1170709 100644 --- a/src/script/bridge/qscriptobject_p.h +++ b/src/script/bridge/qscriptobject_p.h @@ -107,8 +107,8 @@ public: JSC::JSValue data() const; void setData(JSC::JSValue data); - QScriptObjectDelegate *delegate() const; - void setDelegate(QScriptObjectDelegate *delegate); + inline QScriptObjectDelegate *delegate() const; + inline void setDelegate(QScriptObjectDelegate *delegate); protected: Data *d; @@ -158,6 +158,22 @@ private: Q_DISABLE_COPY(QScriptObjectDelegate) }; +inline QScriptObjectDelegate *QScriptObject::delegate() const +{ + if (!d) + return 0; + return d->delegate; +} + +inline void QScriptObject::setDelegate(QScriptObjectDelegate *delegate) +{ + if (!d) + d = new Data(); + else + delete d->delegate; + d->delegate = delegate; +} + QT_END_NAMESPACE #endif -- cgit v0.12