Skip to content

Commit 2cf6396

Browse files
Add ffc.h for string to double parsing
1 parent 288e231 commit 2cf6396

5 files changed

Lines changed: 3486 additions & 11 deletions

File tree

‎cluster_library.c‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ PHP_REDIS_API void cluster_dbl_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *
18371837
}
18381838

18391839
// Convert to double, free response
1840-
dbl = atof(resp);
1840+
dbl = ffc_parse_double_simple(c->reply_len, resp, NULL);
18411841
efree(resp);
18421842

18431843
CLUSTER_RETURN_DOUBLE(c, dbl);
@@ -3052,13 +3052,15 @@ cluster_mbulk_assoc_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
30523052
static int mbulk_resp_loop_dbl(RedisSock *redis_sock, zval *z_result,
30533053
long long count, RedisCmdCtx ctx)
30543054
{
3055-
char *line;
30563055
int line_len;
3056+
char *line;
3057+
double d;
30573058

30583059
while (count--) {
30593060
line = redis_sock_read(redis_sock, &line_len);
30603061
if (line != NULL) {
3061-
add_next_index_double(z_result, atof(line));
3062+
d = ffc_parse_double_simple(line_len, line, NULL);
3063+
add_next_index_double(z_result, d);
30623064
efree(line);
30633065
} else if (EG(exception)) {
30643066
return FAILURE;
@@ -3181,9 +3183,16 @@ static int mbulk_resp_loop_zipdbl(RedisSock *redis_sock, zval *z_result,
31813183
key_len = line_len;
31823184
} else {
31833185
zval zv, *z = &zv;
3186+
double d;
3187+
31843188
redis_unpack(redis_sock,key,key_len, z);
31853189
zend_string *tmp, *zstr = zval_get_tmp_string(z, &tmp);
3186-
add_assoc_double_ex(z_result, ZSTR_VAL(zstr), ZSTR_LEN(zstr), atof(line));
3190+
3191+
d = ffc_parse_double_simple(line_len, line, NULL);
3192+
3193+
add_assoc_double_ex(z_result, ZSTR_VAL(zstr),
3194+
ZSTR_LEN(zstr), d);
3195+
31873196
zend_tmp_string_release(tmp);
31883197
zval_ptr_dtor_nogc(z);
31893198

0 commit comments

Comments
 (0)