Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68365 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47067 invoked from network); 3 Aug 2013 22:56:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2013 22:56:50 -0000 Authentication-Results: pb1.pair.com header.from=ab@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ab@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.73.107 as permitted sender) X-PHP-List-Original-Sender: ab@php.net X-Host-Fingerprint: 85.214.73.107 klapt.com Received: from [85.214.73.107] ([85.214.73.107:43222] helo=h1123647.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/73-26272-0BA8DF15 for ; Sat, 03 Aug 2013 18:56:50 -0400 Received: by h1123647.serverkompetenz.net (Postfix, from userid 1006) id 0A9DB6BC52C; Sun, 4 Aug 2013 00:56:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on h1123647.serverkompetenz.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.5 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 Received: from [192.168.178.7] (dslb-094-216-051-171.pools.arcor-ip.net [94.216.51.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by h1123647.serverkompetenz.net (Postfix) with ESMTPSA id 1C9096BC52A; Sun, 4 Aug 2013 00:56:43 +0200 (CEST) To: Nikita Popov Cc: PHP internals In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Sun, 04 Aug 2013 00:56:39 +0200 Message-ID: <1375570599.9187.58.camel@ghost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Always set return_value_ptr? From: ab@php.net (Anatol Belski) 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