From: Tsuda Kageyu Date: Tue, 29 Nov 2016 05:58:39 +0000 (+0900) Subject: Remove Utils::floatByteOrder() and use systemByteOrder() instead. X-Git-Tag: v1.12-beta-1~105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=046c98230f5f458932fe24bc3e936ed4a47c3ce7;p=taglib 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. --- diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index a2258bc5..3d6daed0 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -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(&tmp), sizeof(TInt)); diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index d4051f64..b114619e 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -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; - } } } }