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:
Tsuda Kageyu 2016-11-29 14:58:39 +09:00
parent 4381bd75f3
commit 046c98230f
2 changed files with 3 additions and 23 deletions

View File

@ -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));

View File

@ -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;
}
}
}
}