QXmlStreamWriter: replace indexed with ranged for loops

Simpler, and fixes the int/qsizetype mismatches.

Pick-to: 6.3 6.2
Task-number: QTBUG-102465
Change-Id: I8ac139a14c4c790348acd76b95d1bee83bb2797d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2022-05-06 01:05:09 +02:00
parent ba741fd310
commit 2438551152

View File

@ -2939,8 +2939,7 @@ void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespa
{
QString escaped;
escaped.reserve(s.size());
for ( int i = 0; i < s.size(); ++i ) {
QChar c = s.at(i);
for (QChar c : s) {
switch (c.unicode()) {
case '<':
escaped.append("&lt;"_L1);
@ -3718,9 +3717,8 @@ void QXmlStreamWriter::writeCurrentToken(const QXmlStreamReader &reader)
break;
case QXmlStreamReader::StartElement: {
writeStartElement(reader.namespaceUri().toString(), reader.name().toString());
QXmlStreamNamespaceDeclarations namespaceDeclarations = reader.namespaceDeclarations();
for (int i = 0; i < namespaceDeclarations.size(); ++i) {
const QXmlStreamNamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(i);
const QXmlStreamNamespaceDeclarations decls = reader.namespaceDeclarations();
for (const auto &namespaceDeclaration : decls) {
writeNamespace(namespaceDeclaration.namespaceUri().toString(),
namespaceDeclaration.prefix().toString());
}