Use ranged for loops instead of QString::utf16

Task-number: QTBUG-98763
Change-Id: I27a854121a783e67afcc4f8634ea7c8c921430c2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Øystein Heskestad 2022-01-05 17:55:31 +01:00
parent 18671b0491
commit 0edbf7f97d
3 changed files with 12 additions and 20 deletions

View File

@ -692,12 +692,8 @@ static QTtfTable generateName(const QList<QTtfNameRecord> &name)
off += len;
}
for (int i = 0; i < name.size(); ++i) {
const QString &n = name.at(i).value;
const ushort *uc = n.utf16();
for (int i = 0; i < n.length(); ++i) {
s << quint16(*uc);
++uc;
}
for (QChar ch : name.at(i).value)
s << quint16(ch.unicode());
}
return t;
}

View File

@ -274,14 +274,11 @@ QString QWindowsFontDatabaseBase::EmbeddedFont::changeFamilyName(const QString &
// nameRecord now points to string data
quint16 *stringStorage = reinterpret_cast<quint16 *>(nameRecord);
const quint16 *sourceString = newFamilyName.utf16();
for (int i = 0; i < newFamilyName.size(); ++i)
stringStorage[i] = qbswap<quint16>(sourceString[i]);
stringStorage += newFamilyName.size();
for (QChar ch : newFamilyName)
*stringStorage++ = qbswap<quint16>(quint16(ch.unicode()));
sourceString = regularString.utf16();
for (int i = 0; i < regularString.size(); ++i)
stringStorage[i] = qbswap<quint16>(sourceString[i]);
for (QChar ch : regularString)
*stringStorage++ = qbswap<quint16>(quint16(ch.unicode()));
}
quint32 *p = reinterpret_cast<quint32 *>(newNameTable.data());

View File

@ -1067,9 +1067,9 @@ static void qStreamNtlmString(QDataStream& ds, const QString& s, bool unicode)
qStreamNtlmBuffer(ds, s.toLatin1());
return;
}
const ushort *d = s.utf16();
for (int i = 0; i < s.length(); ++i)
ds << d[i];
for (QChar ch : s)
ds << quint16(ch.unicode());
}
@ -1210,11 +1210,10 @@ static QByteArray qNtlmPhase1()
static QByteArray qStringAsUcs2Le(const QString& src)
{
QByteArray rc(2*src.length(), 0);
const unsigned short *s = src.utf16();
unsigned short *d = (unsigned short*)rc.data();
for (int i = 0; i < src.length(); ++i) {
d[i] = qToLittleEndian(s[i]);
}
for (QChar ch : src)
*d++ = qToLittleEndian(quint16(ch.unicode()));
return rc;
}