summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-12 05:30:17 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-12 05:30:17 (GMT)
commite16cc0cf7e50a63674a7e36169d0844af6ddb2ce (patch)
tree04a3f8466c2985a7be19913be1d1547f6e117432 /src
parent58fcfaecd1ce82ef19feb25eca8b3bf2f3f3d4c1 (diff)
downloadQt-e16cc0cf7e50a63674a7e36169d0844af6ddb2ce.zip
Qt-e16cc0cf7e50a63674a7e36169d0844af6ddb2ce.tar.gz
Qt-e16cc0cf7e50a63674a7e36169d0844af6ddb2ce.tar.bz2
Optimization: Use linked list for context children
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp59
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h6
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp24
3 files changed, 56 insertions, 33 deletions
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 58de1a7..237cb7e 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -59,12 +59,14 @@ QT_BEGIN_NAMESPACE
QDeclarativeContextPrivate::QDeclarativeContextPrivate()
: parent(0), engine(0), isInternal(false), propertyNames(0),
- notifyIndex(-1), contextObject(0), imports(0), expressions(0), contextObjects(0),
+ notifyIndex(-1), contextObject(0), imports(0), childContexts(0),
+ nextChild(0), prevChild(0), expressions(0), contextObjects(0),
idValues(0), idValueCount(0), optimizedBindings(0)
{
}
-void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::ScriptBlock &script, QObject *scopeObject)
+void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::ScriptBlock &script,
+ QObject *scopeObject)
{
Q_Q(QDeclarativeContext);
@@ -123,8 +125,13 @@ void QDeclarativeContextPrivate::init()
{
Q_Q(QDeclarativeContext);
- if (parent)
- parent->d_func()->childContexts.insert(q);
+ if (parent) {
+ QDeclarativeContextPrivate *ppriv = parent->d_func();
+ nextChild = ppriv->childContexts;
+ if (nextChild) nextChild->d_func()->prevChild = &nextChild;
+ prevChild = &ppriv->childContexts;
+ ppriv->childContexts = q;
+ }
}
/*!
@@ -270,15 +277,24 @@ QDeclarativeContext::QDeclarativeContext(QDeclarativeContext *parentContext, QOb
QDeclarativeContext::~QDeclarativeContext()
{
Q_D(QDeclarativeContext);
- if (d->parent)
- d->parent->d_func()->childContexts.remove(this);
-
- for (QSet<QDeclarativeContext *>::ConstIterator iter = d->childContexts.begin();
- iter != d->childContexts.end();
- ++iter) {
- (*iter)->d_func()->invalidateEngines();
- (*iter)->d_func()->parent = 0;
+
+ if (d->prevChild) {
+ *d->prevChild = d->nextChild;
+ if (d->nextChild) d->nextChild->d_func()->prevChild = d->prevChild;
+ d->nextChild = 0;
+ d->prevChild = 0;
}
+
+ QDeclarativeContext *child = d->childContexts;
+ while (child) {
+ QDeclarativeContextPrivate *childpriv = child->d_func();
+ childpriv->invalidateEngines();
+ childpriv->parent = 0;
+ child = childpriv->nextChild;
+ childpriv->nextChild = 0;
+ childpriv->prevChild = 0;
+ }
+ d->childContexts = 0;
QDeclarativeAbstractExpression *expression = d->expressions;
while (expression) {
@@ -317,10 +333,12 @@ void QDeclarativeContextPrivate::invalidateEngines()
if (!engine)
return;
engine = 0;
- for (QSet<QDeclarativeContext *>::ConstIterator iter = childContexts.begin();
- iter != childContexts.end();
- ++iter) {
- (*iter)->d_func()->invalidateEngines();
+
+ QDeclarativeContext *child = childContexts;
+ while (child) {
+ QDeclarativeContextPrivate *childpriv = child->d_func();
+ childpriv->invalidateEngines();
+ child = childpriv->nextChild;
}
}
@@ -331,10 +349,11 @@ time the context tree *structure* (not values) changes.
*/
void QDeclarativeContextPrivate::refreshExpressions()
{
- for (QSet<QDeclarativeContext *>::ConstIterator iter = childContexts.begin();
- iter != childContexts.end();
- ++iter) {
- (*iter)->d_func()->refreshExpressions();
+ QDeclarativeContext *child = childContexts;
+ while (child) {
+ QDeclarativeContextPrivate *childpriv = child->d_func();
+ childpriv->refreshExpressions();
+ child = childpriv->nextChild;
}
QDeclarativeAbstractExpression *expression = expressions;
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index 682adb5..a1056b1 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -107,7 +107,11 @@ public:
void invalidateEngines();
void refreshExpressions();
- QSet<QDeclarativeContext *> childContexts;
+
+ QDeclarativeContext *childContexts;
+
+ QDeclarativeContext *nextChild;
+ QDeclarativeContext **prevChild;
QDeclarativeAbstractExpression *expressions;
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 3e4acbe..933683c 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -230,22 +230,22 @@ void QDeclarativeEngineDebugServer::buildObjectList(QDataStream &message,
int count = 0;
- for (QSet<QDeclarativeContext *>::ConstIterator iter = p->childContexts.begin();
- iter != p->childContexts.end(); ++iter) {
- QDeclarativeContextPrivate *p = (QDeclarativeContextPrivate *)QObjectPrivate::get(*iter);
- if (p->isInternal)
- continue;
- ++count;
+ QDeclarativeContext *child = p->childContexts;
+ while (child) {
+ QDeclarativeContextPrivate *p = QDeclarativeContextPrivate::get(child);
+ if (!p->isInternal)
+ ++count;
+ child = p->nextChild;
}
message << count;
- for (QSet<QDeclarativeContext *>::ConstIterator iter = p->childContexts.begin();
- iter != p->childContexts.end(); ++iter) {
- QDeclarativeContextPrivate *p = (QDeclarativeContextPrivate *)QObjectPrivate::get(*iter);
- if (p->isInternal)
- continue;
- buildObjectList(message, *iter);
+ child = p->childContexts;
+ while (child) {
+ QDeclarativeContextPrivate *p = QDeclarativeContextPrivate::get(child);
+ if (!p->isInternal)
+ buildObjectList(message, child);
+ child = p->nextChild;
}
// Clean deleted objects