diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-05 18:39:14 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-06 12:23:37 +0000 |
commit | 9b699fa839f560a9ea9da69c8975b9aa4654ab8b (patch) | |
tree | e4a3b79c059bf391163c574f4875f99d209b14ce /src/widgets/styles/qfusionstyle.cpp | |
parent | 9d0dbc32dd3c37c1199115762fab6ac1cedb9ce3 (diff) |
Widgets: use QStringRef to optimize memory allocation
Replace substring functions that return QString with
corresponding functions that return QStringRef where
it's possible.
Create QString from QStringRef only where necessary.
Change-Id: Id1c39093199519f2794b11560c2c0ded2d52b928
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/styles/qfusionstyle.cpp')
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index b15b9701d9..5b6e47e2c6 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1649,7 +1649,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); - QString s = menuitem->text; + QStringRef s(&menuitem->text); if (!s.isEmpty()) { // draw text p->save(); int t = s.indexOf(QLatin1Char('\t')); @@ -1660,12 +1660,13 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (t >= 0) { QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); + const QString textToDraw = s.mid(t + 1).toString(); if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); - p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1)); + p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, textToDraw); p->setPen(discol); } - p->drawText(vShortcutRect, text_flags, s.mid(t + 1)); + p->drawText(vShortcutRect, text_flags, textToDraw); s = s.left(t); } QFont font = menuitem->font; @@ -1680,12 +1681,13 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio font.setBold(true); p->setFont(font); + const QString textToDraw = s.left(t).toString(); if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); - p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t)); + p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw); p->setPen(discol); } - p->drawText(vTextRect, text_flags, s.left(t)); + p->drawText(vTextRect, text_flags, textToDraw); p->restore(); } |