From 0575130b35edcaa244e5797c3d85ba1e5e3f0e86 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Tue, 10 Nov 2020 00:23:47 +0000 Subject: [PATCH] COMMON: Improve ReadStreamEndian implementation The commit does not change the behaviour of the class but makes its implementation more logical, and in line with how it was originaly implemented (before being refactored in commit 1011508). Both FROM_BE_* and TO_BE_* do the same thingi for example, but you use this stream class to read from a BE or LE stream and convert the values to native endianness, and thus it makes more sense to use FROM_BE_* and FROM_LE_* instead of TO_BE_* and TO_LE_* (which suggested that we read values in native endianness and then convert to the specified endianness). --- common/stream.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/stream.h b/common/stream.h index 1dafd841800..64dbc27fe4c 100644 --- a/common/stream.h +++ b/common/stream.h @@ -686,19 +686,19 @@ public: uint16 readUint16() { uint16 val; read(&val, 2); - return (_bigEndian) ? TO_BE_16(val) : TO_LE_16(val); + return (_bigEndian) ? FROM_BE_16(val) : FROM_LE_16(val); } uint32 readUint32() { uint32 val; read(&val, 4); - return (_bigEndian) ? TO_BE_32(val) : TO_LE_32(val); + return (_bigEndian) ? FROM_BE_32(val) : FROM_LE_32(val); } uint64 readUint64() { uint64 val; read(&val, 8); - return (_bigEndian) ? TO_BE_64(val) : TO_LE_64(val); + return (_bigEndian) ? FROM_BE_64(val) : FROM_LE_64(val); } FORCEINLINE int16 readSint16() {