From 046c98230f5f458932fe24bc3e936ed4a47c3ce7 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Tue, 29 Nov 2016 14:58:39 +0900 Subject: [PATCH] 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. --- taglib/toolkit/tbytevector.cpp | 4 ++-- taglib/toolkit/tutils.h | 22 +--------------------- 2 files changed, 3 insertions(+), 23 deletions(-) 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; - } } } } -- 2.40.0