summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-05-13 12:20:39 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-06-24 07:29:03 +0000
commitb6cf0418677729e91e5ccd866afdb22e11385d74 (patch)
tree9101a73b736cd3ebfe02a72cf1e68d7e2326c3aa /src
parent17519feadd7309e125cc64bbac83f73b758c6a60 (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: I728c4338135f83d9cdff4d1ee1aed77f95d453b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp4
-rw-r--r--src/widgets/widgets/qtabbar.cpp6
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index b33984e6c6..774f5a708d 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -1418,7 +1418,7 @@ QStyle::SubControl QAbstractSpinBoxPrivate::newHoverControl(const QPoint &pos)
QString QAbstractSpinBoxPrivate::stripped(const QString &t, int *pos) const
{
- QString text = t;
+ QStringRef text(&t);
if (specialValueText.size() == 0 || text != specialValueText) {
int from = 0;
int size = text.size();
@@ -1440,7 +1440,7 @@ QString QAbstractSpinBoxPrivate::stripped(const QString &t, int *pos) const
text = text.trimmed();
if (pos)
(*pos) -= (s - text.size());
- return text;
+ return text.toString();
}
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 7a192193e4..09b7cb9d24 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -1413,13 +1413,13 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text)
QString ret;
switch (mode) {
case Qt::ElideRight:
- ret = text.left(2) + Ellipses;
+ ret = text.leftRef(2) + Ellipses;
break;
case Qt::ElideMiddle:
- ret = text.left(1) + Ellipses + text.right(1);
+ ret = text.leftRef(1) + Ellipses + text.rightRef(1);
break;
case Qt::ElideLeft:
- ret = Ellipses + text.right(2);
+ ret = Ellipses + text.rightRef(2);
break;
case Qt::ElideNone:
ret = text;
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 45da34c383..df92fc0e1e 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -302,7 +302,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
qWarning("QTextBrowser: No document for %s", url.toString().toLatin1().constData());
if (q->isVisible()) {
- QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1);
+ const QStringRef firstTag = txt.leftRef(txt.indexOf(QLatin1Char('>')) + 1);
if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();