diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-06 09:35:42 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-07 00:51:23 +0200 |
commit | b94ec982c1bbc9cf4e0efdbd0c4b8f14ec4ebdcc (patch) | |
tree | 365d506a365a0d659cd90c64c424ea9ef17c8b43 /src | |
parent | 5beb4f85163fa7b79673e41568944fcc002e0d2b (diff) |
QXmlStreamReader: port Value::len from int to qsizetype
It's a stretch of characters in a QString, so it has to be qsizetype.
This enlarges the Value struct further; created QTBUG-103306 to track
ideas to shrink it again.
Pick-to: 6.3 6.2
Fixes: QTBUG-102465
Change-Id: I753cfd801030c834989452eb5422b2cd72d4ef16
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/serialization/qxmlstream.cpp | 22 | ||||
-rw-r--r-- | src/corelib/serialization/qxmlstream.g | 4 | ||||
-rw-r--r-- | src/corelib/serialization/qxmlstream_p.h | 12 | ||||
-rw-r--r-- | src/corelib/serialization/qxmlstreamparser_p.h | 4 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 3323ff0707..5e3e07f6ee 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -1020,7 +1020,7 @@ bool QXmlStreamReaderPrivate::scanString(const char *str, short tokenToInject, b } textBuffer += QLatin1StringView(str, n); if (requireSpace) { - int s = fastScanSpace(); + const qsizetype s = fastScanSpace(); if (!s || atEnd) { qsizetype pos = textBuffer.size() - n - s; putString(textBuffer, pos); @@ -1132,9 +1132,9 @@ bool QXmlStreamReaderPrivate::scanAttType() encountered. */ -inline int QXmlStreamReaderPrivate::fastScanLiteralContent() +inline qsizetype QXmlStreamReaderPrivate::fastScanLiteralContent() { - int n = 0; + qsizetype n = 0; uint c; while ((c = getChar()) != StreamEOF) { switch (ushort(c)) { @@ -1182,9 +1182,9 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent() return n; } -inline int QXmlStreamReaderPrivate::fastScanSpace() +inline qsizetype QXmlStreamReaderPrivate::fastScanSpace() { - int n = 0; + qsizetype n = 0; uint c; while ((c = getChar()) != StreamEOF) { switch (c) { @@ -1215,9 +1215,9 @@ inline int QXmlStreamReaderPrivate::fastScanSpace() Used for text nodes essentially. That is, characters appearing inside elements. */ -inline int QXmlStreamReaderPrivate::fastScanContentCharList() +inline qsizetype QXmlStreamReaderPrivate::fastScanContentCharList() { - int n = 0; + qsizetype n = 0; uint c; while ((c = getChar()) != StreamEOF) { switch (ushort(c)) { @@ -1279,9 +1279,9 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList() return n; } -inline int QXmlStreamReaderPrivate::fastScanName(qint16 *prefix) +inline qsizetype QXmlStreamReaderPrivate::fastScanName(qint16 *prefix) { - int n = 0; + qsizetype n = 0; uint c; while ((c = getChar()) != StreamEOF) { if (n >= 4096) { @@ -1400,9 +1400,9 @@ static inline NameChar fastDetermineNameChar(QChar ch) return NotName; } -inline int QXmlStreamReaderPrivate::fastScanNMTOKEN() +inline qsizetype QXmlStreamReaderPrivate::fastScanNMTOKEN() { - int n = 0; + qsizetype n = 0; uint c; while ((c = getChar()) != StreamEOF) { if (fastDetermineNameChar(QChar(c)) == NotName) { diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g index db9be6d8ac..201e06ba20 100644 --- a/src/corelib/serialization/qxmlstream.g +++ b/src/corelib/serialization/qxmlstream.g @@ -1217,9 +1217,9 @@ attribute ::= qname space_opt EQ space_opt attribute_value; if (normalize) { // normalize attribute value (simplify and trim) const qsizetype pos = textBuffer.size(); - int n = 0; + qsizetype n = 0; bool wasSpace = true; - for (int i = 0; i < attribute.value.len; ++i) { + for (qsizetype i = 0; i < attribute.value.len; ++i) { QChar c = textBuffer.at(attribute.value.pos + i); if (c.unicode() == ' ') { if (wasSpace) diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index 4897735796..56a40885bb 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -410,7 +410,7 @@ public: int stack_size; struct Value { qsizetype pos; // offset into textBuffer - int len; + qsizetype len; // length incl. prefix (if any) qint16 prefix; // prefix of a name (as in "prefix:name") limited to 4k in fastScanName() ushort c; }; @@ -504,11 +504,11 @@ public: // scan optimization functions. Not strictly necessary but LALR is // not very well suited for scanning fast - int fastScanLiteralContent(); - int fastScanSpace(); - int fastScanContentCharList(); - int fastScanName(qint16 *prefix = nullptr); - inline int fastScanNMTOKEN(); + qsizetype fastScanLiteralContent(); + qsizetype fastScanSpace(); + qsizetype fastScanContentCharList(); + qsizetype fastScanName(qint16 *prefix = nullptr); + inline qsizetype fastScanNMTOKEN(); bool parse(); diff --git a/src/corelib/serialization/qxmlstreamparser_p.h b/src/corelib/serialization/qxmlstreamparser_p.h index de8cfcbd23..b72ab34bea 100644 --- a/src/corelib/serialization/qxmlstreamparser_p.h +++ b/src/corelib/serialization/qxmlstreamparser_p.h @@ -780,9 +780,9 @@ bool QXmlStreamReaderPrivate::parse() if (normalize) { // normalize attribute value (simplify and trim) const qsizetype pos = textBuffer.size(); - int n = 0; + qsizetype n = 0; bool wasSpace = true; - for (int i = 0; i < attribute.value.len; ++i) { + for (qsizetype i = 0; i < attribute.value.len; ++i) { QChar c = textBuffer.at(attribute.value.pos + i); if (c.unicode() == ' ') { if (wasSpace) |