Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 831d611

Browse files
committed
Remove weird macroses
1 parent dfcf52c commit 831d611

2 files changed

Lines changed: 3 additions & 24 deletions

File tree

common.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,6 @@ typedef enum {
210210
REDIS_PROCESS_RESPONSE_CLOSURE(function, NULL) \
211211
}
212212

213-
/* Clear redirection info */
214-
#define REDIS_MOVED_CLEAR(redis_sock) \
215-
redis_sock->redir_slot = 0; \
216-
redis_sock->redir_port = 0; \
217-
redis_sock->redir_type = MOVED_NONE; \
218-
219213
/* Process a command assuming our command where our command building
220214
* function is redis_<cmdname>_cmd */
221215
#define REDIS_PROCESS_CMD(cmdname, resp_func) \
@@ -264,21 +258,6 @@ typedef enum {
264258
#define ZSTR_STRICMP_STATIC(zs, sstr) \
265259
REDIS_STRICMP_STATIC(ZSTR_VAL(zs), ZSTR_LEN(zs), sstr)
266260

267-
/* Extended SET argument detection */
268-
#define ZSTR_IS_EX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "EX")
269-
#define ZSTR_IS_PX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "PX")
270-
#define ZSTR_IS_NX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "NX")
271-
#define ZSTR_IS_XX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "XX")
272-
273-
#define ZVAL_IS_NX_XX_ARG(zv) (ZVAL_STRICMP_STATIC(zv, "NX") || ZVAL_STRICMP_STATIC(zv, "XX"))
274-
#define ZSTR_IS_EX_PX_ARG(a) (ZSTR_IS_EX_ARG(a) || ZSTR_IS_PX_ARG(a))
275-
276-
/* Given a string and length, validate a zRangeByLex argument. The semantics
277-
* here are that the argument must start with '(' or '[' or be just the char
278-
* '+' or '-' */
279-
#define IS_LEX_ARG(s,l) \
280-
(l>0 && (*s=='(' || *s=='[' || (l==1 && (*s=='+' || *s=='-'))))
281-
282261
#define REDIS_ENABLE_MODE(redis_sock, m) (redis_sock->mode |= m)
283262
#define REDIS_DISABLE_MODE(redis_sock, m) (redis_sock->mode &= ~m)
284263

redis_commands.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ int redis_set_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
15751575
ZEND_HASH_FOREACH_STR_KEY_VAL(kt, zkey, v) {
15761576
ZVAL_DEREF(v);
15771577
/* Detect PX or EX argument and validate timeout */
1578-
if (zkey && ZSTR_IS_EX_PX_ARG(zkey)) {
1578+
if (zkey && (ZSTR_STRICMP_STATIC(zkey, "EX") || ZSTR_STRICMP_STATIC(zkey, "PX"))) {
15791579
exp_set = 1;
15801580

15811581
/* Set expire type */
@@ -1592,7 +1592,7 @@ int redis_set_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
15921592
keep_ttl = 1;
15931593
} else if (ZVAL_STRICMP_STATIC((v), "GET")) {
15941594
get = 1;
1595-
} else if (ZVAL_IS_NX_XX_ARG(v)) {
1595+
} else if (ZVAL_STRICMP_STATIC(v, "NX") || ZVAL_STRICMP_STATIC(v, "XX")) {
15961596
set_type = Z_STRVAL_P(v);
15971597
}
15981598
}
@@ -2886,7 +2886,7 @@ int redis_zadd_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
28862886
zval *z_opt;
28872887
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(z_args[1]), z_opt) {
28882888
if (Z_TYPE_P(z_opt) == IS_STRING) {
2889-
if (ZVAL_IS_NX_XX_ARG(z_opt)) {
2889+
if (ZVAL_STRICMP_STATIC(z_opt, "NX") || ZVAL_STRICMP_STATIC(z_opt, "XX")) {
28902890
exp_type = Z_STRVAL_P(z_opt);
28912891
} else if (ZVAL_STRICMP_STATIC(z_opt, "LT") || ZVAL_STRICMP_STATIC(z_opt, "GT")) {
28922892
range_type = Z_STRVAL_P(z_opt);

0 commit comments

Comments
 (0)