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>
This commit is contained in:
parent
c3ca27d02c
commit
1eaf7fd544
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user