summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-05 20:49:18 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-07 13:28:24 +0000
commit1eaf7fd5444f832c9ea820f8087efdd3ac86258f (patch)
tree4be0b2453a1adfca4dcbe6f78f4f652550daf085 /src/widgets/styles
parentc3ca27d02c57c1f3c2865d09b7822c4e86d19fcb (diff)
QStyleSheetStyle: fix some premature pessimizations
- Use QStringView to substring before converting to L1 - cache result of toLatin1() Pick-to: 5.15 Change-Id: I509f551913e77075e60903ebe65b880bd3f7e973 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 8445a4440d..06116ed295 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2597,11 +2597,12 @@ void QStyleSheetStyle::setProperties(QWidget *w)
for (int i = finals.count() - 1; i >= 0; --i) {
const Declaration &decl = decls.at(finals[i]);
- QString property = decl.d->property;
- property.remove(0, 10); // strip "qproperty-"
+ QStringView property = decl.d->property;
+ property = property.mid(10); // strip "qproperty-"
+ const auto propertyL1 = property.toLatin1();
const QMetaObject *metaObject = w->metaObject();
- int index = metaObject->indexOfProperty(property.toLatin1());
+ int index = metaObject->indexOfProperty(propertyL1);
if (Q_UNLIKELY(index == -1)) {
qWarning() << w << " does not have a property named " << property;
continue;
@@ -2613,7 +2614,7 @@ void QStyleSheetStyle::setProperties(QWidget *w)
}
QVariant v;
- const QVariant value = w->property(property.toLatin1());
+ const QVariant value = w->property(propertyL1);
switch (value.userType()) {
case QMetaType::QIcon: v = decl.iconValue(); break;
case QMetaType::QImage: v = QImage(decl.uriValue()); break;
@@ -2628,7 +2629,7 @@ void QStyleSheetStyle::setProperties(QWidget *w)
default: v = decl.d->values.at(0).variant; break;
}
- w->setProperty(property.toLatin1(), v);
+ w->setProperty(propertyL1, v);
}
}