Skip to content

Commit cb41edf

Browse files
committed
Use ZEND_HASH_FOREACH_STR_KEY_VAL when numeric index isn't used
1 parent 0eb1c21 commit cb41edf

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

redis_commands.c

+4-16
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);
@@ -1546,13 +1543,10 @@ int redis_set_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
15461543
if (z_opts && Z_TYPE_P(z_opts) == IS_ARRAY) {
15471544
HashTable *kt = Z_ARRVAL_P(z_opts);
15481545
zend_string *zkey;
1549-
zend_ulong idx;
15501546
zval *v;
15511547

1552-
PHPREDIS_NOTUSED(idx);
1553-
15541548
/* Iterate our option array */
1555-
ZEND_HASH_FOREACH_KEY_VAL(kt, idx, zkey, v) {
1549+
ZEND_HASH_FOREACH_STR_KEY_VAL(kt, zkey, v) {
15561550
ZVAL_DEREF(v);
15571551
/* Detect PX or EX argument and validate timeout */
15581552
if (zkey && ZSTR_IS_EX_PX_ARG(zkey)) {
@@ -3030,15 +3024,12 @@ geoStoreType get_georadius_store_type(zend_string *key) {
30303024

30313025
/* Helper function to extract optional arguments for GEORADIUS and GEORADIUSBYMEMBER */
30323026
static int get_georadius_opts(HashTable *ht, geoOptions *opts) {
3033-
zend_ulong idx;
30343027
char *optstr;
30353028
zend_string *zkey;
30363029
zval *optval;
30373030

3038-
PHPREDIS_NOTUSED(idx);
3039-
30403031
/* Iterate over our argument array, collating which ones we have */
3041-
ZEND_HASH_FOREACH_KEY_VAL(ht, idx, zkey, optval) {
3032+
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, zkey, optval) {
30423033
ZVAL_DEREF(optval);
30433034

30443035
/* If the key is numeric it's a non value option */
@@ -3980,11 +3971,8 @@ static void get_xclaim_options(zval *z_arr, xclaimOptions *opt) {
39803971
zend_string *zkey;
39813972
char *kval;
39823973
size_t klen;
3983-
zend_ulong idx;
39843974
zval *zv;
39853975

3986-
PHPREDIS_NOTUSED(idx);
3987-
39883976
/* Initialize options array to sane defaults */
39893977
memset(opt, 0, sizeof(*opt));
39903978
opt->retrycount = -1;
@@ -3996,7 +3984,7 @@ static void get_xclaim_options(zval *z_arr, xclaimOptions *opt) {
39963984

39973985
/* Iterate over our options array */
39983986
ht = Z_ARRVAL_P(z_arr);
3999-
ZEND_HASH_FOREACH_KEY_VAL(ht, idx, zkey, zv) {
3987+
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, zkey, zv) {
40003988
if (zkey) {
40013989
kval = ZSTR_VAL(zkey);
40023990
klen = ZSTR_LEN(zkey);

0 commit comments

Comments
 (0)