Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Zend/zend_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,26 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
return target;
}

ZEND_API HashTable* zend_array_to_list(HashTable *source)
{
HashTable *result = _zend_new_array(zend_hash_num_elements(source));
zend_hash_real_init_packed(result);

ZEND_HASH_FILL_PACKED(result) {
zval *entry;

ZEND_HASH_FOREACH_VAL(source, entry) {
if (UNEXPECTED(Z_ISREF_P(entry) && Z_REFCOUNT_P(entry) == 1)) {
entry = Z_REFVAL_P(entry);
}
Z_TRY_ADDREF_P(entry);
ZEND_HASH_FILL_ADD(entry);
} ZEND_HASH_FOREACH_END();
} ZEND_HASH_FILL_END();

return result;
}


ZEND_API void ZEND_FASTCALL zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite)
{
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(zval *val1, zval *val2);
ZEND_API uint32_t zend_array_count(HashTable *ht);
ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source);
ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht);
ZEND_API HashTable* zend_array_to_list(HashTable *source);
ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht);
ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht);
ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, bool always_duplicate);
Expand Down
18 changes: 2 additions & 16 deletions ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -4147,8 +4147,7 @@ PHP_FUNCTION(array_key_last)
/* {{{ Return just the values from the input array */
PHP_FUNCTION(array_values)
{
zval *input, /* Input array */
*entry; /* An entry in the input array */
zval *input; /* Input array */
zend_array *arrval;
zend_long arrlen;

Expand All @@ -4170,20 +4169,7 @@ PHP_FUNCTION(array_values)
RETURN_COPY(input);
}

/* Initialize return array */
array_init_size(return_value, arrlen);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));

/* Go through input array and add values to the return array */
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
ZEND_HASH_FOREACH_VAL(arrval, entry) {
if (UNEXPECTED(Z_ISREF_P(entry) && Z_REFCOUNT_P(entry) == 1)) {
entry = Z_REFVAL_P(entry);
}
Z_TRY_ADDREF_P(entry);
ZEND_HASH_FILL_ADD(entry);
} ZEND_HASH_FOREACH_END();
} ZEND_HASH_FILL_END();
RETURN_ARR(zend_array_to_list(arrval));
}
/* }}} */

Expand Down