From 7aeb74ef409a456229848a4e365f725d7ccad23c Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Wed, 21 Oct 2015 18:38:04 +0200 Subject: [PATCH] fast_atof: use gmio_clocale_isdigit() --- src/gmio_core/internal/fast_atof.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gmio_core/internal/fast_atof.h b/src/gmio_core/internal/fast_atof.h index d48653d..fbe3982 100644 --- a/src/gmio_core/internal/fast_atof.h +++ b/src/gmio_core/internal/fast_atof.h @@ -10,6 +10,7 @@ #define GMIO_INTERNAL_FAST_ATOF_H #include "../global.h" +#include "string_utils.h" #include #include @@ -22,10 +23,7 @@ GMIO_INLINE gmio_bool_t is_local_decimal_point(char in) * the float-to-string code used there has to be rewritten first. */ static const char LOCALE_DECIMAL_POINTS[] = { '.' }; - - if (in == LOCALE_DECIMAL_POINTS[0]) - return GMIO_TRUE; - return GMIO_FALSE; + return in == LOCALE_DECIMAL_POINTS[0]; } /* we write [17] here instead of [] to work around a swig bug */ @@ -63,7 +61,7 @@ GMIO_INLINE uint32_t strtoul10(const char* in, const char** out) gmio_bool_t overflow=GMIO_FALSE; uint32_t unsignedValue = 0; - while ( ( *in >= '0') && ( *in <= '9' )) + while ( gmio_clocale_isdigit(*in) ) { const uint32_t tmp = ( unsignedValue * 10 ) + ( *in - '0' ); if (tmp= '0') && (*in <= '9')) + if (gmio_clocale_isdigit(*in)) tmp = (unsignedValue << 4u) + (*in - '0'); else if ((*in >= 'A') && (*in <= 'F')) tmp = (unsignedValue << 4u) + (*in - 'A') + 10; @@ -244,7 +242,7 @@ GMIO_INLINE gmio_float32_t strtof10(const char* in, const char** out) /* Use integer arithmetic for as long as possible, for speed * and precision. */ - while ( ( *in >= '0') && ( *in <= '9' ) ) + while ( gmio_clocale_isdigit(*in) ) { /* If it looks like we're going to overflow, bail out now and start using floating point. */ @@ -256,7 +254,7 @@ GMIO_INLINE gmio_float32_t strtof10(const char* in, const char** out) floatValue = (gmio_float32_t)intValue; /* If there are any digits left to parse, then we need to use * floating point arithmetic from here. */ - while ( ( *in >= '0') && ( *in <= '9' ) ) + while ( gmio_clocale_isdigit(*in) ) { floatValue = (floatValue * 10.f) + (gmio_float32_t)(*in - '0'); ++in;