Skip to content

Commit

Permalink
Fixed formatting issues from clang-format
Browse files Browse the repository at this point in the history
Signed-off-by: Parth Patel <[email protected]>
  • Loading branch information
parthpatel committed Nov 12, 2024
1 parent 87f979f commit 5d3268f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
49 changes: 24 additions & 25 deletions src/fast_float/fast_float_strtod.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,41 @@
#define FAST_FLOAT_STRTOD_H

#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif

#ifdef USE_FAST_FLOAT

/**
* @brief Converts a null-terminated byte string to a double using the fast_float library.
*
* This function provides a C-compatible wrapper around the fast_float library's string-to-double
* conversion functionality. It aims to offer a faster alternative to the standard strtod function.
*
* @param nptr A pointer to the null-terminated byte string to be converted.
* @param value A pointer to the double variable where the function stores converted double value.
* On success, the function stores the converted double value. On failure, it stores
* 0.0 and stores error code in errno to ERANGE or EINVAL.
*
* @return On success, returns char pointer pointing to '\0' at the end of the string.
* On failure, returns char pointer pointing to first invalid character in the string.
*
* @note This function uses the fast_float library (https://github.com/fastfloat/fast_float)
* for the actual conversion, which can be significantly faster than standard library functions.
*
* @see https://github.com/fastfloat/fast_float for more information on the underlying library.
*/
const char* fast_float_strtod(const char *str, double *value);
* @brief Converts a null-terminated byte string to a double using the fast_float library.
*
* This function provides a C-compatible wrapper around the fast_float library's string-to-double
* conversion functionality. It aims to offer a faster alternative to the standard strtod function.
*
* @param nptr A pointer to the null-terminated byte string to be converted.
* @param value A pointer to the double variable where the function stores converted double value.
* On success, the function stores the converted double value. On failure, it stores
* 0.0 and stores error code in errno to ERANGE or EINVAL.
*
* @return On success, returns char pointer pointing to '\0' at the end of the string.
* On failure, returns char pointer pointing to first invalid character in the string.
*
* @note This function uses the fast_float library (https://github.com/fastfloat/fast_float)
* for the actual conversion, which can be significantly faster than standard library functions.
*
* @see https://github.com/fastfloat/fast_float for more information on the underlying library.
*/
const char *fast_float_strtod(const char *str, double *value);

static inline const char* valkey_strtod(const char *str, double *value) {
static inline const char *valkey_strtod(const char *str, double *value) {
errno = 0;
return fast_float_strtod(str, value);
}

#else

static inline const char* valkey_strtod(const char *str, double *value) {
char* endptr;
static inline const char *valkey_strtod(const char *str, double *value) {
char *endptr;
*value = strtod(str, &endptr);
return endptr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/resp_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static int parseDouble(ReplyParser *parser, void *p_ctx) {
if (len <= MAX_LONG_DOUBLE_CHARS) {
memcpy(buf, proto + 1, len);
buf[len] = '\0';
valkey_strtod(buf, &d); /* We expect a valid representation. */
valkey_strtod(buf, &d); /* We expect a valid representation. */
}
parser->callbacks.double_callback(p_ctx, d, proto, parser->curr_location - proto);
return C_OK;
Expand Down

0 comments on commit 5d3268f

Please sign in to comment.