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).
This commit is contained in:
Thierry Crozat 2020-11-10 00:23:47 +00:00
parent a509afdf4d
commit 0575130b35

View File

@ -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() {