QStyleSheetStyle: avoid unnecessary conversions to QString
A lookup to QHash<QString,...> works perfectly fine for a QLatin1StringView so no need to create a QString first. Change-Id: I4cd5f3c0bab8f9af696e8ae2d3eefad77f2e8722 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 55c1630e92914110c7c58f966650d4fe40cfc58c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
79312a5dc7
commit
10c6d0c6e0
@ -592,8 +592,8 @@ public:
|
||||
return csz;
|
||||
}
|
||||
|
||||
bool hasStyleHint(const QString &sh) const { return styleHints.contains(sh); }
|
||||
QVariant styleHint(const QString &sh) const { return styleHints.value(sh); }
|
||||
bool hasStyleHint(QLatin1StringView sh) const { return styleHints.contains(sh); }
|
||||
QVariant styleHint(QLatin1StringView sh) const { return styleHints.value(sh); }
|
||||
|
||||
void fixupBorder(int);
|
||||
|
||||
@ -1027,14 +1027,13 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject *
|
||||
bool knownStyleHint = false;
|
||||
for (const auto sh : knownStyleHints) {
|
||||
QLatin1StringView styleHint(sh);
|
||||
if (decl.d->property.compare(styleHint) == 0) {
|
||||
QString hintName = QString(styleHint);
|
||||
if (decl.d->property == styleHint) {
|
||||
QVariant hintValue;
|
||||
if (hintName.endsWith("alignment"_L1)) {
|
||||
if (styleHint.endsWith("alignment"_L1)) {
|
||||
hintValue = (int) decl.alignmentValue();
|
||||
} else if (hintName.endsWith("color"_L1)) {
|
||||
} else if (styleHint.endsWith("color"_L1)) {
|
||||
hintValue = (int) decl.colorValue().rgba();
|
||||
} else if (hintName.endsWith("size"_L1)) {
|
||||
} else if (styleHint.endsWith("size"_L1)) {
|
||||
// Check only for the 'em' case
|
||||
const QString valueString = decl.d->values.at(0).variant.toString();
|
||||
const bool isEmSize = valueString.endsWith(u"em", Qt::CaseInsensitive);
|
||||
@ -1064,9 +1063,9 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject *
|
||||
// Normal case where we receive a 'px' or 'pt' unit
|
||||
hintValue = decl.sizeValue();
|
||||
}
|
||||
} else if (hintName.endsWith("icon"_L1)) {
|
||||
} else if (styleHint.endsWith("icon"_L1)) {
|
||||
hintValue = decl.iconValue();
|
||||
} else if (hintName == "button-layout"_L1 && decl.d->values.size() != 0
|
||||
} else if (styleHint == "button-layout"_L1 && decl.d->values.size() != 0
|
||||
&& decl.d->values.at(0).type == QCss::Value::String) {
|
||||
hintValue = subControlLayout(decl.d->values.at(0).variant.toString().toLatin1());
|
||||
} else {
|
||||
@ -5642,7 +5641,7 @@ QIcon QStyleSheetStyle::standardIcon(StandardPixmap standardIcon, const QStyleOp
|
||||
const QWidget *w) const
|
||||
{
|
||||
RECURSION_GUARD(return baseStyle()->standardIcon(standardIcon, opt, w))
|
||||
QString s = propertyNameForStandardPixmap(standardIcon);
|
||||
const auto s = propertyNameForStandardPixmap(standardIcon);
|
||||
if (!s.isEmpty()) {
|
||||
QRenderRule rule = renderRule(w, opt);
|
||||
if (rule.hasStyleHint(s))
|
||||
@ -5660,7 +5659,7 @@ QPixmap QStyleSheetStyle::standardPixmap(StandardPixmap standardPixmap, const QS
|
||||
const QWidget *w) const
|
||||
{
|
||||
RECURSION_GUARD(return baseStyle()->standardPixmap(standardPixmap, opt, w))
|
||||
QString s = propertyNameForStandardPixmap(standardPixmap);
|
||||
const auto s = propertyNameForStandardPixmap(standardPixmap);
|
||||
if (!s.isEmpty()) {
|
||||
QRenderRule rule = renderRule(w, opt);
|
||||
if (rule.hasStyleHint(s)) {
|
||||
@ -5689,7 +5688,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
|
||||
return baseStyle()->styleHint(sh, opt, w, shret);
|
||||
|
||||
QRenderRule rule = renderRule(w, opt);
|
||||
QString s;
|
||||
QLatin1StringView s;
|
||||
switch (sh) {
|
||||
case SH_LineEdit_PasswordCharacter: s = "lineedit-password-character"_L1; break;
|
||||
case SH_LineEdit_PasswordMaskDelay: s = "lineedit-password-mask-delay"_L1; break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user