summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qdatastream.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-10 12:37:59 -0800
committerThiago Macieira <thiago.macieira@intel.com>2024-03-12 12:51:43 -0800
commitb18ba91c671f01d4c93470747cd34a2231567e3b (patch)
treec875ec62c584c0d8c605f404b3ae75bde4c190d2 /src/corelib/serialization/qdatastream.h
parent6dfc92abe8796462eacd881cd896313d654df24d (diff)
QDataStream: don't store the byteorder member in Qt 7
It's redundant with the noswap member: we swap if the stream byte order is the opposite of the CPU's and don't swap if it is the same. That the default is to swap is another reason why people should stop using QDataStream (though CBOR also stores numbers in big-endian). Change-Id: I50e2158aeade4256ad1dfffd17b29adc2b698ead Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/serialization/qdatastream.h')
-rw-r--r--src/corelib/serialization/qdatastream.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h
index e7ef94a8a70..36d8a618ff0 100644
--- a/src/corelib/serialization/qdatastream.h
+++ b/src/corelib/serialization/qdatastream.h
@@ -221,7 +221,9 @@ private:
bool noswap = QSysInfo::ByteOrder == QSysInfo::BigEndian;
quint8 fpPrecision = QDataStream::DoublePrecision;
quint8 q_status = Ok;
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
ByteOrder byteorder = BigEndian;
+#endif
int ver = Qt_DefaultCompiledVersion;
quint16 transactionDepth = 0;
@@ -438,7 +440,11 @@ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const
#endif // INLINE_SINCE 6.8
inline QDataStream::ByteOrder QDataStream::byteOrder() const
-{ return byteorder; }
+{
+ if constexpr (QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ return noswap ? BigEndian : LittleEndian;
+ return noswap ? LittleEndian : BigEndian;
+}
inline int QDataStream::version() const
{ return ver; }