summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qtextstream.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-07-30 17:36:14 +0200
committerMÃ¥rten Nordheim <marten.nordheim@qt.io>2020-10-06 11:16:36 +0200
commitfa8d021fa6fcb040fb702b6ffd2deee52a3b748a (patch)
tree15c6a311dcf9e6c64a162ba62d2d9a83846ba159 /src/corelib/serialization/qtextstream.cpp
parent40874625f996899ca1e976f0240da697e784c2c6 (diff)
Convert a couple of APIs to use views
Try to get rid of APIs that use raw 'const {char, QChar} *, length' pairs. Instead, use QByteArrayView or QStringView. As QStringConverter is a new class, simply change the API to what we'd like to have. Also adjust hidden API in QStringBuilder and friends. Change-Id: I897d47f63a7b965f5574a1e51da64147f9e981f6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/serialization/qtextstream.cpp')
-rw-r--r--src/corelib/serialization/qtextstream.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp
index 042dcf6350..137d736b30 100644
--- a/src/corelib/serialization/qtextstream.cpp
+++ b/src/corelib/serialization/qtextstream.cpp
@@ -434,7 +434,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
if (autoDetectUnicode) {
autoDetectUnicode = false;
- auto e = QStringConverter::encodingForData(buf, bytesRead);
+ auto e = QStringConverter::encodingForData(QByteArrayView(buf, bytesRead));
// QStringConverter::Locale implies unknown, so keep the current encoding
if (e) {
encoding = *e;
@@ -452,7 +452,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
#endif
int oldReadBufferSize = readBuffer.size();
- readBuffer += toUtf16(buf, bytesRead);
+ readBuffer += toUtf16(QByteArrayView(buf, bytesRead));
// remove all '\r\n' in the string.
if (readBuffer.size() > oldReadBufferSize && textModeEnabled) {
@@ -2247,7 +2247,7 @@ QTextStream &QTextStream::operator>>(char *c)
}
QStringEncoder encoder(QStringConverter::Utf8);
- char *e = encoder.appendToBuffer(c, ptr, length);
+ char *e = encoder.appendToBuffer(c, QStringView(ptr, length));
*e = '\0';
d->consumeLastToken();
return *this;