From 3a6809a54bee6eba517d7077070c697ecc0b56c3 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 2 Dec 2009 17:36:36 +1000 Subject: Minor performance tweaks --- src/declarative/qml/qmlvme.cpp | 12 +++++++----- src/declarative/qml/qmlvme_p.h | 30 +++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index f2fb217..88c4b60 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -102,7 +103,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledData *comp, int start, int count, const QBitField &bindingSkipList) { - QStack stack; + QmlVMEStack stack; if (start == -1) start = 0; if (count == -1) count = comp->bytecode.count(); @@ -121,14 +122,14 @@ void QmlVME::runDeferred(QObject *object) QmlCompiledData *comp = data->deferredComponent; int start = data->deferredIdx + 1; int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount; - QStack stack; + QmlVMEStack stack; stack.push(object); run(stack, ctxt, comp, start, count, QBitField()); } QBitField bindingSkipList; -QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, +QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, QmlCompiledData *comp, int start, int count, const QBitField &bindingSkipList) @@ -147,7 +148,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlEnginePrivate::SimpleList bindValues; QmlEnginePrivate::SimpleList parserStatus; - QStack qliststack; + QmlVMEStack qliststack; vmeErrors.clear(); QmlEnginePrivate *ep = QmlEnginePrivate::get(ctxt->engine()); @@ -214,7 +215,8 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, // TODO: parent might be a layout } } else { - o->setParent(parent); + QmlGraphics_setParent_noEvent(o, parent); + // o->setParent(parent); } } stack.push(o); diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h index a15bd08..f7b0180 100644 --- a/src/declarative/qml/qmlvme_p.h +++ b/src/declarative/qml/qmlvme_p.h @@ -66,6 +66,34 @@ class QmlCompiledData; class QmlCompiledData; class QmlContext; +template +class QmlVMEStack { +public: + QmlVMEStack() : index(-1), maxSize(N), data(fixedData) {} + ~QmlVMEStack() { if (data != fixedData) qFree(fixedData); } + + bool isEmpty() const { return index == -1; } + const T &top() const { return data[index]; } + void push(const T &i) { ++index; if (index == maxSize) realloc(); data[index] = i; } + const T &pop() { --index; return data[index + 1]; } + int count() const { return index + 1; } + const T &at(int idx) { return data[idx]; } + +private: + void realloc() { + maxSize += N; + if (data != fixedData) { + data = (T*)qRealloc(data, maxSize * sizeof(T)); + } else { + data = (T*)qMalloc(maxSize * sizeof(T)); + } + } + int index; + int maxSize; + T *data; + T fixedData[N]; +}; + class QmlVME { public: @@ -80,7 +108,7 @@ public: QList errors() const; private: - QObject *run(QStack &, QmlContext *, QmlCompiledData *, + QObject *run(QmlVMEStack &, QmlContext *, QmlCompiledData *, int start, int count, const QBitField &); QList vmeErrors; }; -- cgit v0.12