Hi Nikita,

On Sat, 2013-08-03 at 20:16 +0200, Nikita Popov wrote: 
> Why can't we always provide the retval ptr, even for functions that don't
> return by reference? This would allow returning zvals without having to
> copy them first (what RETVAL_ZVAL does).

were it not possible to zval_add_ref() the item one needs to return?
Possibly recursive. I can rebember doing similar to 

array_init(return_value);

for(zend_hash_internal_pointer_reset(Z_ARRVAL_P(my_array));
        zend_hash_has_more_elements(Z_ARRVAL_P(my_array)) == SUCCESS;
        zend_hash_move_forward(Z_ARRVAL_P(my_array)))
    {

    zval **my_array_item;

    if(zend_hash_get_current_data(Z_ARRVAL_P(my_array),
(void**)&my_array_item) == FAILURE) {
        continue;
    }

    zend_hash_get_current_key(Z_ARRVAL_P(my_array), &string_key,
&num_key, 0)
    zval_add_ref(my_array_item);
    zend_hash_update(Z_ARRVAL_P(return_value), string_key,
strlen(string_key), my_array_item, sizeof(zval *), NULL);
}

That's still some overhead, but even in case my_array_item was non
scalar, that should be working. Unfortunately i've no access to that
code anymore. my_array were of course a flat array, for a complex array
it should be done recursive.

Regards

anatol


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to