diff options
| author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2025-05-02 22:07:37 +0200 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2025-06-03 21:39:50 +0200 |
| commit | 15c2ec5344fb8a1e5d4a8e93d410c54563fb86b4 (patch) | |
| tree | 8d5ebe913bf6f3e1ea17d2060f5a355c57936fa3 /src | |
| parent | b02da5f04a11525431a80edd5c00a4d60fc1b89c (diff) | |
QStyleSheetStyle: avoid creating QString
Don't create a QString when comparing the strings from
knownPseudoElements - a QLatin1StringView is enough.
Pick-to: 6.10 6.9
Change-Id: I69e207bac0fb3d3df12ae9d4bebc9cd30cde30de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 530876a6e2b..9859dc370cf 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -247,7 +247,7 @@ struct PseudoElementInfo { const char name[19]; }; -static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { +static constexpr PseudoElementInfo knownPseudoElements[NumPseudoElements] = { { QStyle::SC_None, "" }, { QStyle::SC_None, "down-arrow" }, { QStyle::SC_None, "up-arrow" }, @@ -300,7 +300,7 @@ static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { { QStyle::SC_SliderGroove, "groove" }, { QStyle::SC_SliderHandle, "handle" }, { QStyle::SC_None, "add-page" }, - { QStyle::SC_None, "sub-page"}, + { QStyle::SC_None, "sub-page" }, { QStyle::SC_SliderTickmarks, "tick-mark" }, { QStyle::SC_None, "pane" }, { QStyle::SC_None, "tab-bar" }, @@ -1749,7 +1749,7 @@ QList<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const ///////////////////////////////////////////////////////////////////////////////////////// // Rendering rules -static QList<Declaration> declarations(const QList<StyleRule> &styleRules, const QString &part, +static QList<Declaration> declarations(const QList<StyleRule> &styleRules, QLatin1StringView part, quint64 pseudoClass = PseudoClass_Unspecified) { QList<Declaration> decls; @@ -1898,7 +1898,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, int element, quint6 } - const QString part = QLatin1StringView(knownPseudoElements[element].name); + const auto part = QLatin1StringView(knownPseudoElements[element].name); QList<Declaration> decls = declarations(rules, part, state); QRenderRule newRule(decls, obj); cache[state] = newRule; @@ -2204,7 +2204,7 @@ bool QStyleSheetStyle::hasStyleRule(const QObject *obj, int part) const return result; } - auto pseudoElement = QLatin1StringView(knownPseudoElements[part].name); + const auto pseudoElement = QLatin1StringView(knownPseudoElements[part].name); for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) == 0) { @@ -2671,7 +2671,7 @@ void QStyleSheetStyle::setProperties(QWidget *w) // Set value for each property in the order of property final occurrence // since properties interact. - const QList<Declaration> decls = declarations(styleRules(w), QString()); + const QList<Declaration> decls = declarations(styleRules(w), {}); QList<int> finals; // indices in reverse order of each property's final occurrence { |
