Skip to content

Commit 4452f68

Browse files
committed
Use ZEND_HASH_FOREACH_VAL in redis_sort_cmd
1 parent 142b51d commit 4452f68

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

redis_commands.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,17 +2191,12 @@ int redis_sort_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
21912191
add_next_index_stringl(&z_argv, "GET", sizeof("GET") - 1);
21922192
add_next_index_stringl(&z_argv, Z_STRVAL_P(z_ele), Z_STRLEN_P(z_ele));
21932193
} else {
2194-
HashTable *ht_keys = Z_ARRVAL_P(z_ele);
21952194
int added=0;
2195+
zval *z_key;
21962196

2197-
for(zend_hash_internal_pointer_reset(ht_keys);
2198-
zend_hash_has_more_elements(ht_keys)==SUCCESS;
2199-
zend_hash_move_forward(ht_keys))
2200-
{
2201-
zval *z_key;
2202-
2197+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_ele), z_key) {
22032198
// If we can't get the data, or it's not a string, skip
2204-
if ((z_key = zend_hash_get_current_data(ht_keys)) == NULL || Z_TYPE_P(z_key) != IS_STRING) {
2199+
if (z_key == NULL || Z_TYPE_P(z_key) != IS_STRING) {
22052200
continue;
22062201
}
22072202
/* Add get per thing we're getting */
@@ -2210,7 +2205,7 @@ int redis_sort_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
22102205
// Add this key to our argv array
22112206
add_next_index_stringl(&z_argv, Z_STRVAL_P(z_key), Z_STRLEN_P(z_key));
22122207
added++;
2213-
}
2208+
} ZEND_HASH_FOREACH_END();
22142209

22152210
// Make sure we were able to add at least one
22162211
if(added==0) {

0 commit comments

Comments
 (0)