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>
This commit is contained in:
parent
17519feadd
commit
b6cf041867
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user