summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine_p.h
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-09-02 16:14:01 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-09-02 16:17:13 (GMT)
commite4dfcd4392e5be1b5de8648fc20ff45f7faa30ca (patch)
tree8e1fbb0779b150d556b8d2807271c17090989cb6 /src/script/api/qscriptengine_p.h
parent03274e0f539086cbf58d3fbd8e7e126a0cc16433 (diff)
downloadQt-e4dfcd4392e5be1b5de8648fc20ff45f7faa30ca.zip
Qt-e4dfcd4392e5be1b5de8648fc20ff45f7faa30ca.tar.gz
Qt-e4dfcd4392e5be1b5de8648fc20ff45f7faa30ca.tar.bz2
improve memory management scheme of QScriptString(Private)
Get rid of QPointer. Use linked list of privates (like was recently done for QScriptValue). Allocate the private on the stack when we can. Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/script/api/qscriptengine_p.h')
-rw-r--r--src/script/api/qscriptengine_p.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index f8eee87..826c2da 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -123,7 +123,6 @@ 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);
@@ -219,6 +218,10 @@ public:
inline void unregisterScriptValue(QScriptValuePrivate *value);
void detachAllRegisteredScriptValues();
+ inline void registerScriptString(QScriptStringPrivate *value);
+ inline void unregisterScriptString(QScriptStringPrivate *value);
+ void detachAllRegisteredScriptStrings();
+
// private slots
void _q_objectDestroyed(QObject *);
#endif
@@ -243,6 +246,7 @@ public:
int agentLineNumber;
QScriptValuePrivate *registeredScriptValues;
QScriptValuePrivate *freeScriptValues;
+ QScriptStringPrivate *registeredScriptStrings;
QHash<int, QScriptTypeInfo*> m_typeInfos;
int processEventsInterval;
QScriptValue abortResult;
@@ -364,13 +368,28 @@ inline QScriptValue QScriptValuePrivate::property(const QString &name, int resol
return property(JSC::Identifier(exec, name), resolveMode);
}
-inline QScriptString QScriptEnginePrivate::scriptStringFromJSCIdentifier(const JSC::Identifier &id)
+inline void QScriptEnginePrivate::registerScriptString(QScriptStringPrivate *value)
{
- QScriptString q;
- q.d_ptr = new QScriptStringPrivate(q_func(), id);
- return q;
+ Q_ASSERT(value->type == QScriptStringPrivate::HeapAllocated);
+ value->prev = 0;
+ value->next = registeredScriptStrings;
+ if (registeredScriptStrings)
+ registeredScriptStrings->prev = value;
+ registeredScriptStrings = value;
}
+inline void QScriptEnginePrivate::unregisterScriptString(QScriptStringPrivate *value)
+{
+ Q_ASSERT(value->type == QScriptStringPrivate::HeapAllocated);
+ if (value->prev)
+ value->prev->next = value->next;
+ if (value->next)
+ value->next->prev = value->prev;
+ if (value == registeredScriptStrings)
+ registeredScriptStrings = value->next;
+ value->prev = 0;
+ value->next = 0;
+}
QT_END_NAMESPACE