diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-07-21 23:08:53 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-30 13:18:28 +0200 |
commit | 18307bfffff4cf8867706c9b1eafe163465379a7 (patch) | |
tree | 8bf0cdc7e746a12d34fde439af6c252878730570 /src/declarative/qml/qdeclarativecompiler.cpp | |
parent | bd18281fed1ea614ed40ce947357cf799496fb79 (diff) |
Introduce QHashField for use in "contains" tests.
Change-Id: I35aadace15b71b44c1b9e30a76eadf79fe03afad
Reviewed-on: http://codereview.qt.nokia.com/3767
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativecompiler.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativecompiler.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 9c59787e8e..bb2742c4a3 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -848,6 +848,7 @@ bool QDeclarativeCompiler::buildObject(QDeclarativeParser::Object *obj, const Bi const QMetaObject *metaObject = obj->metaObject(); Q_ASSERT(metaObject); + // XXX aakenned QMetaProperty p = QDeclarativeMetaType::defaultProperty(metaObject); if (p.name()) { Property *explicitProperty = obj->getProperty(QString::fromUtf8(p.name()), false); @@ -2388,8 +2389,8 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) // We use a coarse grain, 31 bit hash to check if there are duplicates. // Calculating the hash for the names is not a waste as we have to test // them against the illegalNames set anyway. - quint32 propNames = 0; - quint32 methodNames = 0; + QHashField propNames; + QHashField methodNames; // Check properties int dpCount = obj->dynamicProperties.count(); @@ -2402,16 +2403,13 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) seenDefaultProperty = true; } - quint32 hash = prop.name.hash(); - quint32 bit = hash % 31; - if (propNames & (1 << bit)) { + if (propNames.testAndSet(prop.name.hash())) { for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p; p2 = obj->dynamicProperties.next(p2)) { if (p2->name == prop.name) COMPILE_EXCEPTION(&prop, tr("Duplicate property name")); } } - propNames |= (1 << bit); if (QDeclarativeUtils::isUpper(prop.name.at(0))) COMPILE_EXCEPTION(&prop, tr("Property names cannot begin with an upper case letter")); |