summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qxmlstream.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-09 16:19:28 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-11 13:17:09 +0200
commit255cc55d74b55dfbecd9af0ea8d39aaf181da4ce (patch)
tree97024af77c5c83c7e075a8dd6d7661b5aee6fc61 /src/corelib/serialization/qxmlstream.cpp
parent3bc9f357714ab7e59cbdf28d0b449d3069dea401 (diff)
QXmlStreamReader: port Private::put...() to QStringView
This enables the use of QChar::fromUcs4() instead of QString::fromUcs4() in a call to putStringLiteral(). Change-Id: I6ed933cc92bfbb70ed2b168b7deeeb466bc6bfeb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/serialization/qxmlstream.cpp')
-rw-r--r--src/corelib/serialization/qxmlstream.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp
index 563fc6ff97..9391b3861a 100644
--- a/src/corelib/serialization/qxmlstream.cpp
+++ b/src/corelib/serialization/qxmlstream.cpp
@@ -1458,36 +1458,40 @@ inline int QXmlStreamReaderPrivate::fastScanNMTOKEN()
return n;
}
-void QXmlStreamReaderPrivate::putString(const QString &s, int from)
+void QXmlStreamReaderPrivate::putString(QStringView s, qsizetype from)
{
+ if (from != 0) {
+ putString(s.mid(from));
+ return;
+ }
putStack.reserve(s.size());
- for (int i = s.size()-1; i >= from; --i)
- putStack.rawPush() = s.at(i).unicode();
+ for (auto it = s.rbegin(), end = s.rend(); it != end; ++it)
+ putStack.rawPush() = it->unicode();
}
-void QXmlStreamReaderPrivate::putStringLiteral(const QString &s)
+void QXmlStreamReaderPrivate::putStringLiteral(QStringView s)
{
putStack.reserve(s.size());
- for (int i = s.size()-1; i >= 0; --i)
- putStack.rawPush() = ((LETTER << 16) | s.at(i).unicode());
+ for (auto it = s.rbegin(), end = s.rend(); it != end; ++it)
+ putStack.rawPush() = ((LETTER << 16) | it->unicode());
}
-void QXmlStreamReaderPrivate::putReplacement(const QString &s)
+void QXmlStreamReaderPrivate::putReplacement(QStringView s)
{
putStack.reserve(s.size());
- for (int i = s.size()-1; i >= 0; --i) {
- ushort c = s.at(i).unicode();
+ for (auto it = s.rbegin(), end = s.rend(); it != end; ++it) {
+ char16_t c = it->unicode();
if (c == '\n' || c == '\r')
putStack.rawPush() = ((LETTER << 16) | c);
else
putStack.rawPush() = c;
}
}
-void QXmlStreamReaderPrivate::putReplacementInAttributeValue(const QString &s)
+void QXmlStreamReaderPrivate::putReplacementInAttributeValue(QStringView s)
{
putStack.reserve(s.size());
- for (int i = s.size()-1; i >= 0; --i) {
- ushort c = s.at(i).unicode();
+ for (auto it = s.rbegin(), end = s.rend(); it != end; ++it) {
+ char16_t c = it->unicode();
if (c == '&' || c == ';')
putStack.rawPush() = c;
else if (c == '\n' || c == '\r')