diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-11-16 05:44:11 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-11-16 05:44:11 (GMT) |
commit | 463786121871c7b0934949f4fcb8ef8b4d64712f (patch) | |
tree | 08932d02e3234633507dc330eb2c8c26cebed45c /src/declarative/qml | |
parent | f2cd51abd592a4da45892e42f0d38803e7c1620e (diff) | |
download | Qt-463786121871c7b0934949f4fcb8ef8b4d64712f.zip Qt-463786121871c7b0934949f4fcb8ef8b4d64712f.tar.gz Qt-463786121871c7b0934949f4fcb8ef8b4d64712f.tar.bz2 |
Optimize string->color conversion in QML.
Reviewed-by: Martin Jones
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qdeclarativestringconverters.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp index 7534a2c..55fae87 100644 --- a/src/declarative/qml/qdeclarativestringconverters.cpp +++ b/src/declarative/qml/qdeclarativestringconverters.cpp @@ -136,7 +136,7 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int p QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok) { - if (s.startsWith(QLatin1Char('#')) && s.length() == 9) { + if (s.length() == 9 && s.startsWith(QLatin1Char('#'))) { uchar a = fromHex(s, 1); uchar r = fromHex(s, 3); uchar g = fromHex(s, 5); @@ -144,9 +144,7 @@ QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok) if (ok) *ok = true; return QColor(r, g, b, a); } else { - QColor rv; - if (s.startsWith(QLatin1Char('#')) || QColor::colorNames().contains(s.toLower())) - rv = QColor(s); + QColor rv(s); if (ok) *ok = rv.isValid(); return rv; } |