QtCore: don't convert single characters to QString for QTextCodec::fromUnicode()
Use the fromUnicode(QChar *, int size) overload instead. Saves 0.5KiB text size on Linux GCC 4.9 AMD64 release builds. Change-Id: I1a1081e09bff4c2116288b8c2616e1bb7ee2bb42 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
a6ddae873b
commit
2463b4452d
@ -632,8 +632,9 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result,
|
||||
int startPos = result.size();
|
||||
|
||||
result.reserve(startPos + str.size() * 3 / 2);
|
||||
const QChar *unicode = str.unicode();
|
||||
for (i = 0; i < str.size(); ++i) {
|
||||
uint ch = str.at(i).unicode();
|
||||
uint ch = unicode[i].unicode();
|
||||
if (ch == ';' || ch == ',' || ch == '=')
|
||||
needsQuotes = true;
|
||||
|
||||
@ -687,7 +688,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result,
|
||||
#ifndef QT_NO_TEXTCODEC
|
||||
} else if (useCodec) {
|
||||
// slow
|
||||
result += codec->fromUnicode(str.at(i));
|
||||
result += codec->fromUnicode(&unicode[i], 1);
|
||||
#endif
|
||||
} else {
|
||||
result += (char)ch;
|
||||
|
@ -3013,7 +3013,8 @@ void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec()
|
||||
#ifndef QT_NO_TEXTCODEC
|
||||
Q_ASSERT(encoder);
|
||||
// assumes ASCII-compatibility for all 8-bit encodings
|
||||
const QByteArray bytes = encoder->fromUnicode(QStringLiteral(" "));
|
||||
QChar space = QLatin1Char(' ');
|
||||
const QByteArray bytes = encoder->fromUnicode(&space, 1);
|
||||
isCodecASCIICompatible = (bytes.count() == 1);
|
||||
#else
|
||||
isCodecASCIICompatible = true;
|
||||
|
Loading…
Reference in New Issue
Block a user