summaryrefslogtreecommitdiffstats
path: root/src/script/api
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-09-01 20:05:57 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-09-02 08:01:00 (GMT)
commit0b5a81dd9aa153f6cd3a3929ee7ed82ca48f45a5 (patch)
tree872442f35c338ec989bcf60f8691d9c0cda2f420 /src/script/api
parent7578f43d0f1358b2ed52b3a5d2b853f26e63aec0 (diff)
downloadQt-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/api')
-rw-r--r--src/script/api/qscriptengine.cpp4
-rw-r--r--src/script/api/qscriptengine_p.h10
-rw-r--r--src/script/api/qscriptstring.cpp10
-rw-r--r--src/script/api/qscriptstring.h1
-rw-r--r--src/script/api/qscriptstring_p.h2
5 files changed, 12 insertions, 15 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;