summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-08 22:02:20 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-11 07:01:30 +0200
commit2e298c5f82c1256e35122205a4bb3093c46a4cb3 (patch)
treee4670b80251b4c7884f9f36376ada4ee4abf83cd /src/corelib/serialization
parent00f6258fb64e6ebf0144d8a6e8fb1515a531b0e4 (diff)
Port qt_to_latin1() (and it's variants) from ushort to char16_t
Change-Id: Id341257f0ac1d6fd1d3176fb34fad253d2bddfb9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/serialization')
-rw-r--r--src/corelib/serialization/qbinaryjson_p.h7
-rw-r--r--src/corelib/serialization/qcborvalue.cpp5
2 files changed, 5 insertions, 7 deletions
diff --git a/src/corelib/serialization/qbinaryjson_p.h b/src/corelib/serialization/qbinaryjson_p.h
index bef2227b7b..3eca794a58 100644
--- a/src/corelib/serialization/qbinaryjson_p.h
+++ b/src/corelib/serialization/qbinaryjson_p.h
@@ -64,7 +64,7 @@ QT_REQUIRE_CONFIG(binaryjson);
QT_BEGIN_NAMESPACE
// in qstring.cpp
-void qt_to_latin1_unchecked(uchar *dst, const ushort *uc, qsizetype len);
+void qt_to_latin1_unchecked(uchar *dst, const char16_t *uc, qsizetype len);
/*
This defines a binary data structure for Json data. The data structure is optimised for fast reading
@@ -281,10 +281,9 @@ public:
static void copy(char *dest, QStringView src)
{
Data *data = reinterpret_cast<Data *>(dest);
- data->length = src.length();
+ data->length = src.length(); // ### narrows from int to ushort
auto *l = reinterpret_cast<uchar *>(data->latin1);
- const auto *uc = reinterpret_cast<const ushort *>(src.utf16());
- qt_to_latin1_unchecked(l, uc, data->length);
+ qt_to_latin1_unchecked(l, src.utf16(), data->length);
for (uint len = data->length; quintptr(l + len) & 0x3; ++len)
l[len] = 0;
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp
index 7d6782cd7f..be22e2c043 100644
--- a/src/corelib/serialization/qcborvalue.cpp
+++ b/src/corelib/serialization/qcborvalue.cpp
@@ -1026,7 +1026,7 @@ void QCborContainerPrivate::replaceAt_complex(Element &e, const QCborValue &valu
}
// in qstring.cpp
-void qt_to_latin1_unchecked(uchar *dst, const ushort *uc, qsizetype len);
+void qt_to_latin1_unchecked(uchar *dst, const char16_t *uc, qsizetype len);
Q_NEVER_INLINE void QCborContainerPrivate::appendAsciiString(QStringView s)
{
@@ -1039,8 +1039,7 @@ Q_NEVER_INLINE void QCborContainerPrivate::appendAsciiString(QStringView s)
char *ptr = data.data() + e.value + sizeof(ByteData);
uchar *l = reinterpret_cast<uchar *>(ptr);
- const ushort *uc = (const ushort *)s.utf16();
- qt_to_latin1_unchecked(l, uc, len);
+ qt_to_latin1_unchecked(l, s.utf16(), len);
}
QCborValue QCborContainerPrivate::extractAt_complex(Element e)