Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e8568d

Browse filesBrowse files
Add ffc.h for string to double parsing
1 parent b37b231 commit 1e8568d
Copy full SHA for 1e8568d

5 files changed

+3,486-11Lines changed: 3486 additions & 11 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cluster_library.c‎

Copy file name to clipboardExpand all lines: cluster_library.c
+13-4Lines 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);
@@ -3025,13 +3025,15 @@ cluster_mbulk_assoc_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
30253025
static int mbulk_resp_loop_dbl(RedisSock *redis_sock, zval *z_result,
30263026
long long count, RedisCmdCtx ctx)
30273027
{
3028-
char *line;
30293028
int line_len;
3029+
char *line;
3030+
double d;
30303031

30313032
while (count--) {
30323033
line = redis_sock_read(redis_sock, &line_len);
30333034
if (line != NULL) {
3034-
add_next_index_double(z_result, atof(line));
3035+
d = ffc_parse_double_simple(line_len, line, NULL);
3036+
add_next_index_double(z_result, d);
30353037
efree(line);
30363038
} else if (EG(exception)) {
30373039
return FAILURE;
@@ -3153,9 +3155,16 @@ static int mbulk_resp_loop_zipdbl(RedisSock *redis_sock, zval *z_result,
31533155
key_len = line_len;
31543156
} else {
31553157
zval zv, *z = &zv;
3158+
double d;
3159+
31563160
redis_unpack(redis_sock,key,key_len, z);
31573161
zend_string *tmp, *zstr = zval_get_tmp_string(z, &tmp);
3158-
add_assoc_double_ex(z_result, ZSTR_VAL(zstr), ZSTR_LEN(zstr), atof(line));
3162+
3163+
d = ffc_parse_double_simple(line_len, line, NULL);
3164+
3165+
add_assoc_double_ex(z_result, ZSTR_VAL(zstr),
3166+
ZSTR_LEN(zstr), d);
3167+
31593168
zend_tmp_string_release(tmp);
31603169
zval_ptr_dtor_nogc(z);
31613170

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.