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>bb10
parent
6dfc92abe8
commit
b18ba91c67
|
|
@ -476,11 +476,14 @@ void QDataStream::setStatus(Status status)
|
|||
|
||||
void QDataStream::setByteOrder(ByteOrder bo)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
|
||||
// accessed by inline byteOrder() prior to Qt 6.8
|
||||
byteorder = bo;
|
||||
#endif
|
||||
if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
|
||||
noswap = (byteorder == BigEndian);
|
||||
noswap = (bo == BigEndian);
|
||||
else
|
||||
noswap = (byteorder == LittleEndian);
|
||||
noswap = (bo == LittleEndian);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue