From cbe67bfd443bc4315c16245fda364ae0b2e7af51 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 3 Dec 2009 17:30:00 +1000 Subject: Optimization: Use QString, not QUrl in QmlBinding --- src/declarative/qml/qmlbinding.cpp | 6 +++--- src/declarative/qml/qmlbinding.h | 2 +- src/declarative/qml/qmlcompiler_p.h | 2 +- src/declarative/qml/qmlcompositetypemanager.cpp | 2 +- src/declarative/qml/qmlexpression.cpp | 16 ++++++++-------- src/declarative/qml/qmlexpression.h | 6 +++--- src/declarative/qml/qmlexpression_p.h | 4 ++-- src/declarative/qml/qmlvme.cpp | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index f0bfd98..f9fc2d2 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -111,7 +111,7 @@ QmlBindingPrivate::QmlBindingPrivate() { } -QmlBinding::QmlBinding(void *data, QmlRefCount *rc, QObject *obj, QmlContext *ctxt, const QUrl &url, int lineNumber, QObject *parent) +QmlBinding::QmlBinding(void *data, QmlRefCount *rc, QObject *obj, QmlContext *ctxt, const QString &url, int lineNumber, QObject *parent) : QmlExpression(ctxt, data, rc, obj, url, lineNumber, *new QmlBindingPrivate) { setParent(parent); @@ -177,7 +177,7 @@ void QmlBinding::update(QmlMetaProperty::WriteFlags flags) if (isUndefined && !data->error.isValid()) { - QUrl url = data->url; + QUrl url = QUrl(data->url); int line = data->line; if (url.isEmpty()) url = QUrl(QLatin1String("")); @@ -189,7 +189,7 @@ void QmlBinding::update(QmlMetaProperty::WriteFlags flags) } else if (!isUndefined && data->property.object() && !data->property.write(value, flags)) { - QUrl url = data->url; + QUrl url = QUrl(data->url); int line = data->line; if (url.isEmpty()) url = QUrl(QLatin1String("")); diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h index 8fbe441..ce768a6 100644 --- a/src/declarative/qml/qmlbinding.h +++ b/src/declarative/qml/qmlbinding.h @@ -92,7 +92,7 @@ class Q_DECLARATIVE_EXPORT QmlBinding : public QmlExpression, Q_OBJECT public: QmlBinding(const QString &, QObject *, QmlContext *, QObject *parent=0); - QmlBinding(void *, QmlRefCount *, QObject *, QmlContext *, const QUrl &, int, + QmlBinding(void *, QmlRefCount *, QObject *, QmlContext *, const QString &, int, QObject *parent); ~QmlBinding(); diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 298719f..8c48c63 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -79,7 +79,7 @@ public: QmlCompiledData(); virtual ~QmlCompiledData(); - QByteArray name; + QString name; QUrl url; QmlEnginePrivate::Imports imports; QmlTypeNameCache *importCache; diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index fa68951..2566e63 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -119,7 +119,7 @@ QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine) compiledComponent = new QmlCompiledData; compiledComponent->url = imports.baseUrl(); - compiledComponent->name = compiledComponent->url.toString().toUtf8(); + compiledComponent->name = compiledComponent->url.toString(); QmlCompiler compiler; if (!compiler.compile(engine, this, compiledComponent)) { diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index d7a6496..276b118 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -91,7 +91,7 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, const QString &expr, } void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, - QObject *me, const QUrl &url, int lineNumber) + QObject *me, const QString &url, int lineNumber) { data->url = url; data->line = lineNumber; @@ -120,7 +120,7 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, if (!dd->cachedClosures.at(progIdx)) { QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); scriptContext->pushScope(ep->contextClass->newSharedContext()); - dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url.toString(), data->line)); + dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line)); scriptEngine->popContext(); } @@ -133,7 +133,7 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, #if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work? if (!dd->cachedPrograms.at(progIdx)) { dd->cachedPrograms[progIdx] = - new QScriptProgram(data->expression, data->url.toString(), data->line); + new QScriptProgram(data->expression, data->url, data->line); } #endif @@ -174,7 +174,7 @@ QmlExpression::QmlExpression() /*! \internal */ QmlExpression::QmlExpression(QmlContext *ctxt, void *expr, QmlRefCount *rc, QObject *me, - const QUrl &url, int lineNumber, + const QString &url, int lineNumber, QmlExpressionPrivate &dd) : QObject(dd, 0) { @@ -331,7 +331,7 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUnd if (data->expressionRewritten) { data->expressionFunction = scriptEngine->evaluate(data->expression, - data->url.toString(), data->line); + data->url, data->line); } else { QmlRewrite::RewriteBinding rewriteBinding; @@ -341,7 +341,7 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUnd scriptEngine->popContext(); return QVariant(); } - data->expressionFunction = scriptEngine->evaluate(code, data->url.toString(), data->line); + data->expressionFunction = scriptEngine->evaluate(code, data->url, data->line); } scriptEngine->popContext(); @@ -521,7 +521,7 @@ void QmlExpression::setTrackChange(bool trackChange) Returns the source file URL for this expression. The source location must have been previously set by calling setSourceLocation(). */ -QUrl QmlExpression::sourceFile() const +QString QmlExpression::sourceFile() const { Q_D(const QmlExpression); return d->data->url; @@ -541,7 +541,7 @@ int QmlExpression::lineNumber() const Set the location of this expression to \a line of \a url. This information is used by the script engine. */ -void QmlExpression::setSourceLocation(const QUrl &url, int line) +void QmlExpression::setSourceLocation(const QString &url, int line) { Q_D(QmlExpression); d->data->url = url; diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h index cbea58a..34783b2 100644 --- a/src/declarative/qml/qmlexpression.h +++ b/src/declarative/qml/qmlexpression.h @@ -77,9 +77,9 @@ public: bool trackChange() const; void setTrackChange(bool); - QUrl sourceFile() const; + QString sourceFile() const; int lineNumber() const; - void setSourceLocation(const QUrl &fileName, int line); + void setSourceLocation(const QString &fileName, int line); QObject *scopeObject() const; @@ -96,7 +96,7 @@ Q_SIGNALS: protected: QmlExpression(QmlContext *, const QString &, QObject *, QmlExpressionPrivate &dd); - QmlExpression(QmlContext *, void *, QmlRefCount *rc, QObject *me, const QUrl &, + QmlExpression(QmlContext *, void *, QmlRefCount *rc, QObject *me, const QString &, int, QmlExpressionPrivate &dd); private Q_SLOTS: diff --git a/src/declarative/qml/qmlexpression_p.h b/src/declarative/qml/qmlexpression_p.h index 98ef856..6beeaec 100644 --- a/src/declarative/qml/qmlexpression_p.h +++ b/src/declarative/qml/qmlexpression_p.h @@ -103,7 +103,7 @@ public: bool isShared; - QUrl url; + QString url; // This is a QString for a reason. QUrls are slooooooow... int line; struct SignalGuard : public QGuard { @@ -143,7 +143,7 @@ public: }; void init(QmlContext *, const QString &, QObject *); - void init(QmlContext *, void *, QmlRefCount *, QObject *, const QUrl &, int); + void init(QmlContext *, void *, QmlRefCount *, QObject *, const QString &, int); QmlExpressionData *data; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 89ca1be..d080268 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -544,7 +544,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, QmlBoundSignal *bs = new QmlBoundSignal(target, signal, target); QmlExpression *expr = new QmlExpression(ctxt, primitives.at(instr.storeSignal.value), target); - expr->setSourceLocation(comp->url, instr.line); + expr->setSourceLocation(comp->name, instr.line); bs->setExpression(expr); } break; @@ -597,7 +597,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, if (stack.count() == 1 && bindingSkipList.testBit(coreIndex)) break; - QmlBinding *bind = new QmlBinding((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, comp->url, instr.line, 0); + QmlBinding *bind = new QmlBinding((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, comp->name, instr.line, 0); bindValues.append(bind); bind->m_mePtr = &bindValues.values[bindValues.count - 1]; bind->setTarget(mp); -- cgit v0.12