summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAnton Kudryavtsev <antkudr@mail.ru>2017-03-29 07:10:46 +0300
committerAnton Kudryavtsev <antkudr@mail.ru>2017-03-30 20:31:59 +0000
commit5ec57560c0b497f9f48671dd200bb23d1f6eac35 (patch)
tree66903177b84d4fc481c8c4e689f47e79aa1a622c /src/corelib
parentce124d511917f95bd9193ec71f747f490ec982da (diff)
Prefer rvalue versions of toLatin() and toUtf8()
... to re-use existing buffers. Change-Id: I7c42529b8cd4400520a59e658ab76f4f8e965cd4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qsettings_mac.cpp2
-rw-r--r--src/corelib/io/qurl.cpp6
-rw-r--r--src/corelib/tools/qlocale_win.cpp13
-rw-r--r--src/corelib/tools/qregularexpression.cpp2
-rw-r--r--src/corelib/tools/qtimezoneprivate_icu.cpp2
-rw-r--r--src/corelib/tools/qtimezoneprivate_win.cpp2
6 files changed, 11 insertions, 16 deletions
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index cf3a480623..2a08ee2e64 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -211,7 +211,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value)
default:
QString string = QSettingsPrivate::variantToString(value);
if (string.contains(QChar::Null))
- result = string.toUtf8().toCFData();
+ result = std::move(string).toUtf8().toCFData();
else
result = string.toCFString();
}
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index b5772b5ce2..9663235a67 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3418,8 +3418,7 @@ QUrl QUrl::adjusted(QUrl::FormattingOptions options) const
QByteArray QUrl::toEncoded(FormattingOptions options) const
{
options &= ~(FullyDecoded | FullyEncoded);
- QString stringForm = toString(options | FullyEncoded);
- return stringForm.toLatin1();
+ return toString(options | FullyEncoded).toLatin1();
}
/*!
@@ -3536,8 +3535,7 @@ QString QUrl::fromAce(const QByteArray &domain)
*/
QByteArray QUrl::toAce(const QString &domain)
{
- QString result = qt_ACE_do(domain, ToAceOnly, ForbidLeadingDot /*FIXME: make configurable*/);
- return result.toLatin1();
+ return qt_ACE_do(domain, ToAceOnly, ForbidLeadingDot /*FIXME: make configurable*/).toLatin1();
}
/*!
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp
index d1abb8b565..2475859abd 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/tools/qlocale_win.cpp
@@ -1037,7 +1037,7 @@ static QString winIso639LangName(LPWSTR id)
if (!lang_code.isEmpty()) {
const char *endptr;
bool ok;
- QByteArray latin1_lang_code = lang_code.toLatin1();
+ QByteArray latin1_lang_code = std::move(lang_code).toLatin1();
int i = qstrtoull(latin1_lang_code, &endptr, 16, &ok);
if (ok && *endptr == '\0') {
switch (i) {
@@ -1120,15 +1120,12 @@ static QByteArray getWinLocaleName(LPWSTR id)
id = lcName;
}
#endif // Q_OS_WINRT
- QString resultuage = winIso639LangName(id);
+ QString resultusage = winIso639LangName(id);
QString country = winIso3116CtryName(id);
- result = resultuage.toLatin1();
- if (!country.isEmpty()) {
- result += '_';
- result += country.toLatin1();
- }
+ if (!country.isEmpty())
+ resultusage += QLatin1Char('_') + country;
- return result;
+ return std::move(resultusage).toLatin1();
}
Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id)
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 8366e01ee8..f1fac093b0 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -1674,7 +1674,7 @@ QString QRegularExpression::errorString() const
} while (errorStringLength < 0);
errorString.resize(errorStringLength);
- return QCoreApplication::translate("QRegularExpression", errorString.toLatin1().constData());
+ return QCoreApplication::translate("QRegularExpression", std::move(errorString).toLatin1().constData());
}
return QCoreApplication::translate("QRegularExpression", "no error");
}
diff --git a/src/corelib/tools/qtimezoneprivate_icu.cpp b/src/corelib/tools/qtimezoneprivate_icu.cpp
index 887486f567..a7226f2720 100644
--- a/src/corelib/tools/qtimezoneprivate_icu.cpp
+++ b/src/corelib/tools/qtimezoneprivate_icu.cpp
@@ -98,7 +98,7 @@ static QByteArray ucalDefaultTimeZoneId()
// If successful on first or second go, resize and return
if (U_SUCCESS(status)) {
result.resize(size);
- return result.toUtf8();
+ return std::move(result).toUtf8();
}
return QByteArray();
diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp
index 16dfaefb74..f963e10333 100644
--- a/src/corelib/tools/qtimezoneprivate_win.cpp
+++ b/src/corelib/tools/qtimezoneprivate_win.cpp
@@ -299,7 +299,7 @@ static QByteArray windowsSystemZoneId()
id = readRegistryString(key, L"TimeZoneKeyName");
RegCloseKey(key);
if (!id.isEmpty())
- return id.toUtf8();
+ return std::move(id).toUtf8();
}
// On XP we have to iterate over the zones until we find a match on