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>
This commit is contained in:
parent
5beb4f8516
commit
b94ec982c1
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user