libstl: use strtof() if available (in stla_read.c)
strtof() is faster than strtod(), see: http://www.gnu.org/software/libc/manual/html_node/Parsing-of-Floats.html "(...) strtof can be substantially faster than strtod, but has less precision" strtof() was added in C99 so BUILD_STRICT_C90 must be disabled to have any chance to use it (MSVC does not provide strtof(), GCC does).
This commit is contained in:
parent
5f0f9f9273
commit
90f5f084f6
@ -219,10 +219,15 @@ static int eat_string(foug_stream_fwd_iterator_t* it, foug_string_buffer_t* str_
|
||||
|
||||
static int get_real32(const char* str, foug_real32_t* value_ptr)
|
||||
{
|
||||
char* conv_end_ptr; /* for strtod() */
|
||||
char* end_ptr; /* for strtod() */
|
||||
|
||||
*value_ptr = (foug_real32_t)strtod(str, &conv_end_ptr);
|
||||
if (conv_end_ptr == str || errno == ERANGE)
|
||||
#ifdef FOUG_HAVE_STRTOF_FUNC
|
||||
*value_ptr = strtof(str, &end_ptr); /* Requires C99 */
|
||||
#else
|
||||
*value_ptr = (foug_real32_t)strtod(str, &end_ptr);
|
||||
#endif
|
||||
|
||||
if (end_ptr == str || errno == ERANGE)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user