From 5d8b07bd6ad6550ce6464973c5132580589a96a2 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 5 Mar 2012 12:23:19 +0100 Subject: [PATCH] Don't needlessly create alias property names in the meta-object When aliases should not be resolved, there is no need to create the alias name StringRef, since it would occupy space in the meta-data even though the string was never actually initialized. Similarly, when aliases should be resolved, it's enough to create the StringRef once. Change-Id: I44dfe665fe8d7bd5754bc939ff62ad75efe19d5b Reviewed-by: Aaron Kennedy --- src/qml/qml/ftw/qfastmetabuilder.cpp | 3 ++- src/qml/qml/qqmlcompiler.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/ftw/qfastmetabuilder.cpp b/src/qml/qml/ftw/qfastmetabuilder.cpp index 02f5091..08ea76b 100644 --- a/src/qml/qml/ftw/qfastmetabuilder.cpp +++ b/src/qml/qml/ftw/qfastmetabuilder.cpp @@ -197,7 +197,8 @@ void QFastMetaBuilder::setProperty(int index, const StringRef &name, const Strin QMetaType::Type mtype, PropertyFlag flags, int notifySignal) { Q_ASSERT(!m_data.isEmpty()); - Q_ASSERT(!name.isEmpty() && !type.isEmpty()); + Q_ASSERT(!name.isEmpty()); + Q_ASSERT(!type.isEmpty()); QMetaObjectPrivate *p = priv(m_data); Q_ASSERT(index < p->propertyCount); diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index 23c4adc..1ae8240 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -2865,7 +2865,8 @@ bool QQmlCompiler::buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mod for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { // Reserve space for name - p->nameRef = builder.newString(p->name.utf8length()); + if (p->type != Object::DynamicProperty::Alias || resolveAlias) + p->nameRef = builder.newString(p->name.utf8length()); int propertyType = 0; bool readonly = false; @@ -3231,6 +3232,8 @@ bool QQmlCompiler::compileAlias(QFastMetaBuilder &builder, int propIndex, int aliasIndex, Object::DynamicProperty &prop) { + Q_ASSERT(!prop.nameRef.isEmpty()); + Q_ASSERT(prop.typeRef.isEmpty()); if (!prop.defaultValue) COMPILE_EXCEPTION(obj, tr("No property alias location")); @@ -3325,7 +3328,6 @@ bool QQmlCompiler::compileAlias(QFastMetaBuilder &builder, VMD *vmd = (QQmlVMEMetaData *)data.data(); *(vmd->aliasData() + aliasIndex) = aliasData; - prop.nameRef = builder.newString(prop.name.utf8length()); prop.resolvedCustomTypeName = pool->NewByteArray(typeName); prop.typeRef = builder.newString(typeName.length()); -- 2.7.4