8000 Switch pipeline_cmd from smart_str to smart_string · phpredis/phpredis@571ffbc · GitHub
[go: up one dir, main page]

Skip to content

Commit 571ffbc

Browse files
JakubOnderkamichael-grunder
authored andcommitted
Switch pipeline_cmd from smart_str to smart_string
As we don't need to extract zend_string from pipeline_cmd, we can use simple smart_string structure
1 parent 7895636 commit 571ffbc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ typedef enum {
177177
#define IS_PIPELINE(redis_sock) (redis_sock->mode & PIPELINE)
178178

179179
#define PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len) do { \
180-
smart_str_appendl(&redis_sock->pipeline_cmd, cmd, cmd_len); \
180+
smart_string_appendl(&redis_sock->pipeline_cmd, cmd, cmd_len); \
181181
} while (0)
182182

183183
#define REDIS_SAVE_CALLBACK(callback, closure_context) do { \
@@ -318,7 +318,7 @@ typedef struct {
318318
struct fold_item *head;
319319
struct fold_item *current;
320320

321-
smart_str pipeline_cmd;
321+
smart_string pipeline_cmd;
322322

323323
zend_string *err;
324324

library.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3564,7 +3564,7 @@ PHP_REDIS_API void redis_free_socket(RedisSock *redis_sock)
35643564
if (redis_sock->prefix) {
35653565
zend_string_release(redis_sock->prefix);
35663566
}
3567-
smart_str_free(&redis_sock->pipeline_cmd);
3567+
smart_string_free(&redis_sock->pipeline_cmd);
35683568
if (redis_sock->err) {
35693569
zend_string_release(redis_sock->err);
35703570
}

redis.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ PHP_METHOD(Redis, discard)
19481948

19491949
if (IS_PIPELINE(redis_sock)) {
19501950
ret = SUCCESS;
1951-
smart_str_free(&redis_sock->pipeline_cmd);
1951+
smart_string_free(&redis_sock->pipeline_cmd);
19521952
} else if (IS_MULTI(redis_sock)) {
19531953
ret = redis_send_discard(redis_sock);
19541954
}
@@ -2025,12 +2025,12 @@ PHP_METHOD(Redis, exec)
20252025
}
20262026

20272027
if (IS_PIPELINE(redis_sock)) {
2028-
if (smart_str_get_len(&redis_sock->pipeline_cmd) == 0) {
2028+
if (redis_sock->pipeline_cmd.len == 0) {
20292029
/* Empty array when no command was run. */
20302030
ZVAL_EMPTY_ARRAY(&z_ret);
20312031
} else {
2032-
if (redis_sock_write(redis_sock, ZSTR_VAL(redis_sock->pipeline_cmd.s),
2033-
ZSTR_LEN(redis_sock->pipeline_cmd.s)) < 0) {
2032+
if (redis_sock_write(redis_sock, redis_sock->pipeline_cmd.c,
2033+
redis_sock->pipeline_cmd.len) < 0) {
20342034
ZVAL_FALSE(&z_ret);
20352035
} else {
20362036
array_init(&z_ret);
@@ -2040,7 +2040,7 @@ PHP_METHOD(Redis, exec)
20402040
ZVAL_FALSE(&z_ret);
20412041
}
20422042
}
2043-
smart_str_free(&redis_sock->pipeline_cmd);
2043+
smart_string_free(&redis_sock->pipeline_cmd);
20442044
}
20452045
free_reply_callbacks(redis_sock);
20462046
REDIS_DISABLE_MODE(redis_sock, PIPELINE);

0 commit comments

Comments
 (0)
0