mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Remove Utils::floatByteOrder() and use systemByteOrder() instead.
We can safely assume that the integer and float byte orders are the same on IEEE754 compliant systems.
This commit is contained in:
parent
4381bd75f3
commit
046c98230f
@ -176,7 +176,7 @@ TFloat toFloat(const ByteVector &v, size_t offset)
|
||||
} tmp;
|
||||
::memcpy(&tmp, v.data() + offset, sizeof(TInt));
|
||||
|
||||
if(ENDIAN != Utils::floatByteOrder())
|
||||
if(ENDIAN != Utils::systemByteOrder())
|
||||
tmp.i = Utils::byteSwap(tmp.i);
|
||||
|
||||
return tmp.f;
|
||||
@ -191,7 +191,7 @@ ByteVector fromFloat(TFloat value)
|
||||
} tmp;
|
||||
tmp.f = value;
|
||||
|
||||
if(ENDIAN != Utils::floatByteOrder())
|
||||
if(ENDIAN != Utils::systemByteOrder())
|
||||
tmp.i = Utils::byteSwap(tmp.i);
|
||||
|
||||
return ByteVector(reinterpret_cast<char *>(&tmp), sizeof(TInt));
|
||||
|
@ -233,7 +233,7 @@ namespace TagLib
|
||||
};
|
||||
|
||||
/*!
|
||||
* Returns the integer byte order of the system.
|
||||
* Returns the byte order of the system.
|
||||
*/
|
||||
inline ByteOrder systemByteOrder()
|
||||
{
|
||||
@ -248,26 +248,6 @@ namespace TagLib
|
||||
else
|
||||
return BigEndian;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the IEEE754 byte order of the system.
|
||||
*/
|
||||
inline ByteOrder floatByteOrder()
|
||||
{
|
||||
union {
|
||||
double d;
|
||||
char c;
|
||||
} u;
|
||||
|
||||
// 1.0 is stored in memory like 0x3FF0000000000000 in canonical form.
|
||||
// So the first byte is zero if little endian.
|
||||
|
||||
u.d = 1.0;
|
||||
if(u.c == 0)
|
||||
return LittleEndian;
|
||||
else
|
||||
return BigEndian;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user