unread
Hello Xinchen,
Analogue to the array_slice implementation, the array_reverse function could also be optimized for packed hash tables when preserve_keys is false (most common).
The following patch should do just that:
if (!preserve_keys && (Z_ARRVAL_P(input)->u.flags & HASH_FLAG_PACKED)) {
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(input), entry) {
ZEND_HASH_FILL_ADD(entry);
zval_add_ref(entry);
} ZEND_HASH_FOREACH_END();
} ZEND_HASH_FILL_END();
}
Please let me know your thoughts.
Thanks,
Ben
--
Bejamin Coutu
ben.coutu@zeyos.com
ZeyOS, Inc.
http://www.zeyos.com