QtNetwork: use QStringRef to optimize memory allocation

Replace substring functions that return QString with
corresponding functions that return QStringRef where
it's possible.

Change-Id: Id7f70e5bd72c91ed210ec463aad1d84fe3b40c15
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Anton Kudryavtsev 2016-05-12 19:02:33 +03:00
parent 6cbc9c6d35
commit 874eb8b44b
4 changed files with 4 additions and 4 deletions

View File

@ -1218,7 +1218,7 @@ bool QFtpPI::startNextCmd()
pendingCommands.pop_front();
#if defined(QFTPPI_DEBUG)
qDebug("QFtpPI send: %s", currentCmd.left(currentCmd.length()-2).toLatin1().constData());
qDebug("QFtpPI send: %s", currentCmd.leftRef(currentCmd.length() - 2).toLatin1().constData());
#endif
state = Waiting;
commandSocket.write(currentCmd.toUtf8());

View File

@ -160,7 +160,7 @@ static inline bool isParentDomain(const QString &domain, const QString &referenc
if (!reference.startsWith(QLatin1Char('.')))
return domain == reference;
return domain.endsWith(reference) || domain == reference.mid(1);
return domain.endsWith(reference) || domain == reference.midRef(1);
}
/*!

View File

@ -1015,7 +1015,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
netmask = parser.prefixLength();
} else {
bool ok;
netmask = subnet.mid(slash + 1).toUInt(&ok);
netmask = subnet.midRef(slash + 1).toUInt(&ok);
if (!ok)
return invalid; // failed to parse the subnet
}

View File

@ -323,7 +323,7 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
pos = entry.indexOf(QLatin1Char(':'), server);
if (pos != -1) {
bool ok;
uint value = entry.mid(pos + 1).toUInt(&ok);
uint value = entry.midRef(pos + 1).toUInt(&ok);
if (!ok || value > 65535)
continue; // invalid port number