]> granicus.if.org Git - taglib/commitdiff
Remove Utils::floatByteOrder() and use systemByteOrder() instead.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 29 Nov 2016 05:58:39 +0000 (14:58 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 29 Nov 2016 05:58:39 +0000 (14:58 +0900)
We can safely assume that the integer and float byte orders are the same on IEEE754 compliant systems.

taglib/toolkit/tbytevector.cpp
taglib/toolkit/tutils.h

index a2258bc5d9e04440ed86fa7cfafd7c54f5fd2325..3d6daed02d0c6b13e6ec99d746238c5d69ed13ed 100644 (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));
index d4051f642e2e0eb201541603304d6f38ec90b5d7..b114619e0f5f912f8afe33d9bb015ed7e9cc9309 100644 (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;
-      }
     }
   }
 }