From b2c1ddf00ba2c3395dbfca417540153ea173a870 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Sat, 3 Oct 2009 00:08:03 +1000 Subject: Use QMetaObject::indexOfProperty() This is both more efficient, and allows the creation of dynamic properties. --- src/declarative/qml/qmlpropertycache.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp index 300bbf6..63ce00c 100644 --- a/src/declarative/qml/qmlpropertycache.cpp +++ b/src/declarative/qml/qmlpropertycache.cpp @@ -111,14 +111,10 @@ QmlPropertyCache::Data QmlPropertyCache::create(const QMetaObject *metaObject, QmlPropertyCache::Data rv; - int propCount = metaObject->propertyCount(); - for (int ii = propCount - 1; ii >= 0; --ii) { - QMetaProperty p = metaObject->property(ii); - QString propName = QLatin1String(p.name()); - if (propName == property) { - rv.load(p); - return rv; - } + int idx = metaObject->indexOfProperty(property.toUtf8()); + if (idx != -1) { + rv.load(metaObject->property(idx)); + return rv; } int methodCount = metaObject->methodCount(); -- cgit v0.12