From a21ed515051efe493f64156f134ba8ac76c10ab3 Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 31 May 2018 22:45:45 +0200 Subject: [PATCH] Improve coding style in toFloat{32,64}() functions * Use const * Don't duplicate BE/LE branches --- conversion/binaryconversionprivate.h | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/conversion/binaryconversionprivate.h b/conversion/binaryconversionprivate.h index 339ede6..dd18749 100644 --- a/conversion/binaryconversionprivate.h +++ b/conversion/binaryconversionprivate.h @@ -113,15 +113,9 @@ CPP_UTILITIES_EXPORT constexpr uint64 toUInt64(const char *value) */ CPP_UTILITIES_EXPORT inline float32 toFloat32(const char *value) { -#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 - int32 val = toInt32(value); - char *c = reinterpret_cast(&val); - return *reinterpret_cast(c); -#else - int32 val = toInt32(value); - char *c = reinterpret_cast(&val); - return *reinterpret_cast(c); -#endif + const int32 val = toInt32(value); + const char *const c = reinterpret_cast(&val); + return *reinterpret_cast(c); } /*! @@ -129,15 +123,9 @@ CPP_UTILITIES_EXPORT inline float32 toFloat32(const char *value) */ CPP_UTILITIES_EXPORT inline float64 toFloat64(const char *value) { -#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0 - int64 val = toInt64(value); - char *c = reinterpret_cast(&val); - return *reinterpret_cast(c); -#else - int64 val = toInt64(value); - char *c = reinterpret_cast(&val); - return *reinterpret_cast(c); -#endif + const int64 val = toInt64(value); + const char *const c = reinterpret_cast(&val); + return *reinterpret_cast(c); } /*!