diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-07-15 17:46:43 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-30 13:18:28 +0200 |
commit | c742d2d12122e752a74da3e3f26dff28ff967b9d (patch) | |
tree | 0ba053e34da0681a5a61fa6d36602ffdabef6e0e /src/declarative/qml/qdeclarativeparser.cpp | |
parent | 3f7ea11f9f9a0ecb2bc571237f8f3523447883f7 (diff) |
Improve performance of the QML front-end
Introduced a new lexer and a more efficient representation of
the AST. Instead of creating unique name ids, we simply use
QStringRef(s).
Change-Id: I403472fa2bb74d2c87dd6314065306499677a3bf
Authored-by: Roberto Raggi
Reviewed-on: http://codereview.qt.nokia.com/3750
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativeparser.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeparser.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp index eca085868c..9f08ae8dc0 100644 --- a/src/declarative/qml/qdeclarativeparser.cpp +++ b/src/declarative/qml/qdeclarativeparser.cpp @@ -132,17 +132,17 @@ void QDeclarativeParser::Object::addScriptStringProperty(Property *p) scriptStringProperties.append(p); } -Property *QDeclarativeParser::Object::getProperty(const QString *name, bool create) +Property *QDeclarativeParser::Object::getProperty(const QStringRef &name, bool create) { for (Property *p = properties.first(); p; p = properties.next(p)) { - if (p->name() == *name) + if (p->name() == name) return p; } if (create) { Property *property = pool()->New<Property>(); property->parent = this; - property->_name = const_cast<QString *>(name); + property->_name = name; property->isDefault = false; properties.prepend(property); return property; @@ -161,7 +161,7 @@ Property *QDeclarativeParser::Object::getProperty(const QString &name, bool crea if (create) { Property *property = pool()->New<Property>(); property->parent = this; - property->_name = pool()->NewString(name); + property->_name = QStringRef(pool()->NewString(name)); property->isDefault = false; properties.prepend(property); return property; @@ -288,7 +288,8 @@ bool QDeclarativeParser::Variant::asBoolean() const QString QDeclarativeParser::Variant::asString() const { if (t == String) { - return l->value->asString(); + // XXX aakenned + return l->value.toString(); } else { return asWritten.toString(); } @@ -358,9 +359,10 @@ QString QDeclarativeParser::Variant::asScript() const case String: return escapedString(asString()); case Script: - if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(n)) - return i->name->asString(); - else + if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(n)) { + // XXX aakenned + return i->name.toString(); + } else return asWritten.toString(); } } @@ -416,7 +418,7 @@ QStringList QDeclarativeParser::Variant::asStringList() const AST::StringLiteral *string = AST::cast<AST::StringLiteral *>(elements->expression); if (!string) return QStringList(); - rv.append(string->value->asString()); + rv.append(string->value.toString()); elements = elements->next; } |