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

Skip to content

Commit 6008900

Browse files
yatsukhnenkomichael-grunder
authored andcommitted
Use ZEND_HASH_FOREACH_STR_KEY_VAL when numeric index isn't used
1 parent 12ffbf3 commit 6008900

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

redis_commands.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,8 @@ int redis_zrangebyscore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
564564
size_t key_len, start_len, end_len;
565565
zval *z_opt=NULL, *z_ele;
566566
zend_string *zkey;
567-
zend_ulong idx;
568567
HashTable *ht_opt;
569568

570-
PHPREDIS_NOTUSED(idx);
571-
572569
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|a", &key, &key_len,
573570
&start, &start_len, &end, &end_len, &z_opt)
574571
==FAILURE)
@@ -579,7 +576,7 @@ int redis_zrangebyscore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
579576
// Check for an options array
580577
if (z_opt && Z_TYPE_P(z_opt) == IS_ARRAY) {
581578
ht_opt = Z_ARRVAL_P(z_opt);
582-
ZEND_HASH_FOREACH_KEY_VAL(ht_opt, idx, zkey, z_ele) {
579+
ZEND_HASH_FOREACH_STR_KEY_VAL(ht_opt, zkey, z_ele) {
583580
/* All options require a string key type */
584581
if (!zkey) continue;
585582
ZVAL_DEREF(z_ele);
@@ -1343,13 +1340,10 @@ int redis_set_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
13431340
if (z_opts && Z_TYPE_P(z_opts) == IS_ARRAY) {
13441341
HashTable *kt = Z_ARRVAL_P(z_opts);
13451342
zend_string *zkey;
1346-
zend_ulong idx;
13471343
zval *v;
13481344

1349-
PHPREDIS_NOTUSED(idx);
1350-
13511345
/* Iterate our option array */
1352-
ZEND_HASH_FOREACH_KEY_VAL(kt, idx, zkey, v) {
1346+
ZEND_HASH_FOREACH_STR_KEY_VAL(kt, zkey, v) {
13531347
ZVAL_DEREF(v);
13541348
/* Detect PX or EX argument and validate timeout */
13551349
if (zkey && ZSTR_IS_EX_PX_ARG(zkey)) {
@@ -2784,15 +2778,12 @@ geoStoreType get_georadius_store_type(zend_string *key) {
27842778

27852779
/* Helper function to extract optional arguments for GEORADIUS and GEORADIUSBYMEMBER */
27862780
static int get_georadius_opts(HashTable *ht, geoOptions *opts) {
2787-
zend_ulong idx;
27882781
char *optstr;
27892782
zend_string *zkey;
27902783
zval *optval;
27912784

2792-
PHPREDIS_NOTUSED(idx);
2793-
27942785
/* Iterate over our argument array, collating which ones we have */
2795-
ZEND_HASH_FOREACH_KEY_VAL(ht, idx, zkey, optval) {
2786+
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, zkey, optval) {
27962787
ZVAL_DEREF(optval);
27972788

27982789
/* If the key is numeric it's a non value option */
@@ -3680,11 +3671,8 @@ static void get_xclaim_options(zval *z_arr, xclaimOptions *opt) {
36803671
zend_string *zkey;
36813672
char *kval;
36823673
size_t klen;
3683-
zend_ulong idx;
36843674
zval *zv;
36853675

3686-
PHPREDIS_NOTUSED(idx);
3687-
36883676
/* Initialize options array to sane defaults */
36893677
memset(opt, 0, sizeof(*opt));
36903678
opt->retrycount = -1;
@@ -3696,7 +3684,7 @@ static void get_xclaim_options(zval *z_arr, xclaimOptions *opt) {
36963684

36973685
/* Iterate over our options array */
36983686
ht = Z_ARRVAL_P(z_arr);
3699-
ZEND_HASH_FOREACH_KEY_VAL(ht, idx, zkey, zv) {
3687+
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, zkey, zv) {
37003688
if (zkey) {
37013689
kval = ZSTR_VAL(zkey);
37023690
klen = ZSTR_LEN(zkey);

0 commit comments

Comments
 (0)