Replace QString::trimmed() with QStringRef::trimmed()
... where it's possible. Reduce allocations. Change-Id: I023adfd316f94948fe50749f60bf55748dca56e2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
802c31bdbd
commit
5dc739ba9b
@ -1418,16 +1418,16 @@ static bool setFloatAttribute(qreal *destination, const QString &value)
|
||||
return ok;
|
||||
}
|
||||
|
||||
static void setWidthAttribute(QTextLength *width, QString value)
|
||||
static void setWidthAttribute(QTextLength *width, const QString &valueStr)
|
||||
{
|
||||
bool ok = false;
|
||||
qreal realVal = value.toDouble(&ok);
|
||||
qreal realVal = valueStr.toDouble(&ok);
|
||||
if (ok) {
|
||||
*width = QTextLength(QTextLength::FixedLength, realVal);
|
||||
} else {
|
||||
value = value.trimmed();
|
||||
QStringRef value = QStringRef(&valueStr).trimmed();
|
||||
if (!value.isEmpty() && value.endsWith(QLatin1Char('%'))) {
|
||||
value.chop(1);
|
||||
value.truncate(value.size() - 1);
|
||||
realVal = value.toDouble(&ok);
|
||||
if (ok)
|
||||
*width = QTextLength(QTextLength::PercentageLength, realVal);
|
||||
|
@ -2034,7 +2034,7 @@ int QFtp::rename(const QString &oldname, const QString &newname)
|
||||
*/
|
||||
int QFtp::rawCommand(const QString &command)
|
||||
{
|
||||
QString cmd = command.trimmed() + QLatin1String("\r\n");
|
||||
const QString cmd = QStringRef(&command).trimmed() + QLatin1String("\r\n");
|
||||
return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));
|
||||
}
|
||||
|
||||
@ -2253,8 +2253,8 @@ void QFtpPrivate::_q_startNextCommand()
|
||||
// Proxy support, replace the Login argument in place, then fall
|
||||
// through.
|
||||
if (c->command == QFtp::Login && !proxyHost.isEmpty()) {
|
||||
QString loginString = c->rawCmds.constFirst().trimmed();
|
||||
loginString += QLatin1Char('@') + host;
|
||||
QString loginString;
|
||||
loginString += QStringRef(&c->rawCmds.constFirst()).trimmed() + QLatin1Char('@') + host;
|
||||
if (port && port != 21)
|
||||
loginString += QLatin1Char(':') + QString::number(port);
|
||||
loginString += QLatin1String("\r\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user