summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-20 18:39:09 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-20 18:39:09 (GMT)
commit435c87186ff54ebfd481e41e07b9a136fbc87a20 (patch)
tree7e2828d49207e44cb7533b850e2e33ed85efa097 /src/script/api/qscriptengine.cpp
parent1a1a3dcff288b9f4256357aa376596f12e661d2e (diff)
downloadQt-435c87186ff54ebfd481e41e07b9a136fbc87a20.zip
Qt-435c87186ff54ebfd481e41e07b9a136fbc87a20.tar.gz
Qt-435c87186ff54ebfd481e41e07b9a136fbc87a20.tar.bz2
implement registered script values as a doubly linked list
It's faster.
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 9fc2f72..6fde08f 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -791,7 +791,7 @@ static QScriptValue __setupPackage__(QScriptContext *ctx, QScriptEngine *eng)
} // namespace QScript
QScriptEnginePrivate::QScriptEnginePrivate()
- : inEval(false)
+ : registeredScriptValues(0), inEval(false)
{
qMetaTypeId<QScriptValue>();
@@ -1139,11 +1139,10 @@ void QScriptEnginePrivate::mark()
variantPrototype->mark();
{
- QList<QScriptValuePrivate*>::const_iterator it;
- for (it = registeredScriptValues.constBegin(); it != registeredScriptValues.constEnd(); ++it) {
- QScriptValuePrivate *val = *it;
- if (val->isJSC() && !val->jscValue.marked())
- val->jscValue.mark();
+ QScriptValuePrivate *it;
+ for (it = registeredScriptValues; it != 0; it = it->next) {
+ if (it->isJSC() && !it->jscValue.marked())
+ it->jscValue.mark();
}
}
@@ -1365,19 +1364,36 @@ bool QScriptEnginePrivate::scriptDisconnect(JSC::JSValue signal, JSC::JSValue re
void QScriptEnginePrivate::registerScriptValue(QScriptValuePrivate *value)
{
- registeredScriptValues.append(value);
+ value->prev = 0;
+ value->next = registeredScriptValues;
+ if (registeredScriptValues)
+ registeredScriptValues->prev = value;
+ registeredScriptValues = value;
}
void QScriptEnginePrivate::unregisterScriptValue(QScriptValuePrivate *value)
{
- registeredScriptValues.removeOne(value);
+ if (value->prev)
+ value->prev->next = value->next;
+ if (value->next)
+ value->next->prev = value->prev;
+ if (value == registeredScriptValues)
+ registeredScriptValues = value->next;
+ value->prev = 0;
+ value->next = 0;
}
void QScriptEnginePrivate::detachAllRegisteredScriptValues()
{
- for (int i = 0; i < registeredScriptValues.size(); ++i)
- registeredScriptValues.at(i)->detachFromEngine();
- registeredScriptValues.clear();
+ QScriptValuePrivate *it;
+ QScriptValuePrivate *next;
+ for (it = registeredScriptValues; it != 0; it = next) {
+ it->detachFromEngine();
+ next = it->next;
+ it->prev = 0;
+ it->next = 0;
+ }
+ registeredScriptValues = 0;
}
#ifdef QT_NO_QOBJECT