|
32 | 32 | #define FAST_FLOAT_STRTOD_H
|
33 | 33 |
|
34 | 34 | #ifdef __cplusplus
|
35 |
| -extern "C" |
36 |
| -{ |
| 35 | +extern "C" { |
37 | 36 | #endif
|
38 | 37 |
|
39 | 38 | #ifdef USE_FAST_FLOAT
|
40 |
| - |
| 39 | + |
41 | 40 | /**
|
42 |
| - * @brief Converts a null-terminated byte string to a double using the fast_float library. |
43 |
| - * |
44 |
| - * This function provides a C-compatible wrapper around the fast_float library's string-to-double |
45 |
| - * conversion functionality. It aims to offer a faster alternative to the standard strtod function. |
46 |
| - * |
47 |
| - * @param nptr A pointer to the null-terminated byte string to be converted. |
48 |
| - * @param value A pointer to the double variable where the function stores converted double value. |
49 |
| - * On success, the function stores the converted double value. On failure, it stores |
50 |
| - * 0.0 and stores error code in errno to ERANGE or EINVAL. |
51 |
| - * |
52 |
| - * @return On success, returns char pointer pointing to '\0' at the end of the string. |
53 |
| - * On failure, returns char pointer pointing to first invalid character in the string. |
54 |
| - * |
55 |
| - * @note This function uses the fast_float library (https://github.com/fastfloat/fast_float) |
56 |
| - * for the actual conversion, which can be significantly faster than standard library functions. |
57 |
| - * |
58 |
| - * @see https://github.com/fastfloat/fast_float for more information on the underlying library. |
59 |
| - */ |
60 |
| -const char* fast_float_strtod(const char *str, double *value); |
| 41 | + * @brief Converts a null-terminated byte string to a double using the fast_float library. |
| 42 | + * |
| 43 | + * This function provides a C-compatible wrapper around the fast_float library's string-to-double |
| 44 | + * conversion functionality. It aims to offer a faster alternative to the standard strtod function. |
| 45 | + * |
| 46 | + * @param nptr A pointer to the null-terminated byte string to be converted. |
| 47 | + * @param value A pointer to the double variable where the function stores converted double value. |
| 48 | + * On success, the function stores the converted double value. On failure, it stores |
| 49 | + * 0.0 and stores error code in errno to ERANGE or EINVAL. |
| 50 | + * |
| 51 | + * @return On success, returns char pointer pointing to '\0' at the end of the string. |
| 52 | + * On failure, returns char pointer pointing to first invalid character in the string. |
| 53 | + * |
| 54 | + * @note This function uses the fast_float library (https://github.com/fastfloat/fast_float) |
| 55 | + * for the actual conversion, which can be significantly faster than standard library functions. |
| 56 | + * |
| 57 | + * @see https://github.com/fastfloat/fast_float for more information on the underlying library. |
| 58 | + */ |
| 59 | +const char *fast_float_strtod(const char *str, double *value); |
61 | 60 |
|
62 |
| -static inline const char* valkey_strtod(const char *str, double *value) { |
| 61 | +static inline const char *valkey_strtod(const char *str, double *value) { |
63 | 62 | errno = 0;
|
64 | 63 | return fast_float_strtod(str, value);
|
65 | 64 | }
|
66 | 65 |
|
67 | 66 | #else
|
68 | 67 |
|
69 |
| -static inline const char* valkey_strtod(const char *str, double *value) { |
70 |
| - char* endptr; |
| 68 | +static inline const char *valkey_strtod(const char *str, double *value) { |
| 69 | + char *endptr; |
71 | 70 | *value = strtod(str, &endptr);
|
72 | 71 | return endptr;
|
73 | 72 | }
|
|
0 commit comments