From c901e373c8402d2542b708831deb4a5773624b1b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 3 Dec 2009 17:00:44 +1000 Subject: Avoid QString <-> QUrl conversions --- src/declarative/qml/qmlcompileddata.cpp | 10 ++++++++++ src/declarative/qml/qmlcompiler.cpp | 2 +- src/declarative/qml/qmlcompiler_p.h | 2 ++ src/declarative/qml/qmlvme.cpp | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qmlcompileddata.cpp b/src/declarative/qml/qmlcompileddata.cpp index c4a0b59..c41ee3f 100644 --- a/src/declarative/qml/qmlcompileddata.cpp +++ b/src/declarative/qml/qmlcompileddata.cpp @@ -85,6 +85,16 @@ int QmlCompiledData::indexForByteArray(const QByteArray &data) return idx; } +int QmlCompiledData::indexForUrl(const QUrl &data) +{ + int idx = urls.indexOf(data); + if (idx == -1) { + idx = urls.count(); + urls << data; + } + return idx; +} + int QmlCompiledData::indexForFloat(float *data, int count) { Q_ASSERT(count > 0); diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index c8e9fa3..578aa91 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -374,7 +374,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop, instr.type = QmlInstruction::StoreUrl; QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string)); instr.storeUrl.propertyIndex = prop.propertyIndex(); - instr.storeUrl.value = output->indexForString(u.toString()); + instr.storeUrl.value = output->indexForUrl(u); } break; case QVariant::UInt: diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index f7f72e7..298719f 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -118,6 +118,7 @@ public: QList propertyCaches; QList contextCaches; QList scripts; + QList urls; void dumpInstructions(); private: @@ -134,6 +135,7 @@ private: int indexForInt(int *, int); int indexForLocation(const QmlParser::Location &); int indexForLocation(const QmlParser::LocationSpan &); + int indexForUrl(const QUrl &); }; class QMetaObjectBuilder; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 6107ebf..89ca1be 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -144,6 +144,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, const QList &floatData = comp->floatData; const QList &propertyCaches = comp->propertyCaches; const QList &scripts = comp->scripts; + const QList &urls = comp->urls; QmlEnginePrivate::SimpleList bindValues; QmlEnginePrivate::SimpleList parserStatus; @@ -297,8 +298,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, case QmlInstruction::StoreUrl: { QObject *target = stack.top(); - QUrl u(primitives.at(instr.storeUrl.value)); - void *a[] = { &u, 0, &status, &flags }; + void *a[] = { (void *)&urls.at(instr.storeUrl.value), 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeUrl.propertyIndex, a); } -- cgit v0.12