diff --git a/src/corelib/serialization/qbinaryjson_p.h b/src/corelib/serialization/qbinaryjson_p.h index bef2227b7b0..3eca794a588 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(dest); - data->length = src.length(); + data->length = src.length(); // ### narrows from int to ushort auto *l = reinterpret_cast(data->latin1); - const auto *uc = reinterpret_cast(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 7d6782cd7f8..be22e2c0437 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(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) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index fd15dfe157c..bd8f536587c 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -143,7 +143,7 @@ char16_t *to_utf16(ushort *p) { return reinterpret_cast(p); } // From qstring_mips_dsp_asm.S extern "C" void qt_fromlatin1_mips_asm_unroll4 (char16_t*, const char*, uint); extern "C" void qt_fromlatin1_mips_asm_unroll8 (char16_t*, const char*, uint); -extern "C" void qt_toLatin1_mips_dsp_asm(uchar *dst, const ushort *src, int length); +extern "C" void qt_toLatin1_mips_dsp_asm(uchar *dst, const char16_t *src, int length); #endif // internal @@ -675,7 +675,7 @@ void qt_from_latin1(char16_t *dst, const char *str, size_t size) noexcept } template -static void qt_to_latin1_internal(uchar *dst, const ushort *src, qsizetype length) +static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype length) { #if defined(__SSE2__) uchar *e = dst + length; @@ -831,12 +831,12 @@ static void qt_to_latin1_internal(uchar *dst, const ushort *src, qsizetype lengt #endif } -static void qt_to_latin1(uchar *dst, const ushort *src, qsizetype length) +static void qt_to_latin1(uchar *dst, const char16_t *src, qsizetype length) { qt_to_latin1_internal(dst, src, length); } -void qt_to_latin1_unchecked(uchar *dst, const ushort *src, qsizetype length) +void qt_to_latin1_unchecked(uchar *dst, const char16_t *src, qsizetype length) { qt_to_latin1_internal(dst, src, length); } @@ -5137,7 +5137,7 @@ static QByteArray qt_convert_to_latin1(QStringView string) // since we own the only copy, we're going to const_cast the constData; // that avoids an unnecessary call to detach() and expansion code that will never get used qt_to_latin1(reinterpret_cast(const_cast(ba.constData())), - reinterpret_cast(string.data()), string.length()); + string.utf16(), string.size()); return ba; } @@ -5148,7 +5148,7 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) // We can return our own buffer to the caller. // Conversion to Latin-1 always shrinks the buffer by half. - const ushort *data = s.d.data(); + const char16_t *data = to_utf16(s.d.data()); int length = s.d.size; // Move the d pointer over to the bytearray. @@ -5162,8 +5162,8 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) char *ddata = ba_d.data(); - // multiply the allocated capacity by sizeof(ushort) - ba_d.d_ptr()->alloc *= sizeof(ushort); + // multiply the allocated capacity by sizeof(char16_t) + ba_d.d_ptr()->alloc *= sizeof(char16_t); // do the in-place conversion qt_to_latin1(reinterpret_cast(ddata), data, length);