Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68712 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6721 invoked from network); 30 Aug 2013 09:43:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2013 09:43:59 -0000 Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.182 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.220.182 mail-vc0-f182.google.com Received: from [209.85.220.182] ([209.85.220.182:62254] helo=mail-vc0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/97-64695-D5960225 for ; Fri, 30 Aug 2013 05:43:58 -0400 Received: by mail-vc0-f182.google.com with SMTP id hf12so1152222vcb.13 for ; Fri, 30 Aug 2013 02:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=uUp5DgoCJ5wuHMymPGn9mDrf+x2l+WNrB4k5EMHiOIo=; b=KmV4mB78ONMyf3aXw+F3yBHo2qihmfRvQmStYHY7pCHe85JAP5YtGgdbDjxBwzUNyc C/O2hIi+2QmL2Mm6rT/Pxh3ZrKCm0R5CB6/JTcwB/4LAhAIsxzLdm9YP1KpRG3WqWl+v 7G1Tzf5+qUKQbldheOIpVdJnh6VJh7TNgRw1DMSZWdVXgmeaTAcp05685JWBz/2QOr7j LdW7u9nMP1z+KclkA8V3UTjTADLja0i+/VLboftmeFGbKGhJVjk3nSBuYdAPDUl9AKHv h1gkmPeFVpY06Wpu9ZiUoEbd2afnyEu9yfR6+k5v46tm1RHe2CVdU1IjnsVVLi6qAqPm H7UQ== X-Received: by 10.220.46.72 with SMTP id i8mr7504342vcf.10.1377855835080; Fri, 30 Aug 2013 02:43:55 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.73.197 with HTTP; Fri, 30 Aug 2013 02:43:14 -0700 (PDT) In-Reply-To: <521FE78E.3060900@gmail.com> References: <521FE78E.3060900@gmail.com> Date: Fri, 30 Aug 2013 11:43:14 +0200 X-Google-Sender-Auth: Z23RR3AaE9kSoKdnW1DOl1HTAyc Message-ID: To: Terry Ellison Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=001a11c2c6749a109c04e5270f28 Subject: Re: [PHP-DEV] Re: Always set return_value_ptr? From: jpauli@php.net (Julien Pauli) --001a11c2c6749a109c04e5270f28 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Aug 30, 2013 at 2:30 AM, Terry Ellison wrote: > On 27/08/13 10:40, Nikita Popov wrote: > >> On Sat, Aug 3, 2013 at 8:16 PM, Nikita Popov >> wrote: >> >> Hi internals! >>> >>> Is there any particular reason why we only pass return_value_ptr to >>> internal functions if they have the ACC_RETURN_REFERENCE flag set? >>> >>> 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). >>> >>> Motivation for this is the following SO question: >>> http://stackoverflow.com/q/**17844379/385378 >>> >>> Patch for this change can be found here: >> https://github.com/php/php-**src/pull/420 >> >> The patch also adds new macros to allow easy use of this feature called >> RETVAL_ZVAL_FAST/RETURN_ZVAL_**FAST (anyone got a better name?) >> >> If no one objects I'll merge this sometime soon. >> > +1 Though looking through the ext uses, most functions returning an array > build it directly in return_value and thus avoid the copy. I also see that > you've picked up all of the cases in ext/standard/array.c where these > macros can be applied. > > There's another one in string.c, in PHP_FUNCTION(pathinfo), that could be > applied as well, though there's little performance gain in avoiding the > copy of a 4 element string array. > > BTW, looking at this pathinfo code, it doesn't do what the documentation > says it does -- or at least this states that the optional argument if > present should be _one_ of PATHINFO_DIRNAME, PATHINFO_BASENAME, > PATHINFO_EXTENSION or PATHINFO_FILENAME. However, if a bitmask is supplied > then this function returns the element corresponding to the lowest bit > value rather than an error return, for example: > > $ php -r 'echo pathinfo("/tmp/x.fred", PATHINFO_FILENAME|PATHINFO_** > EXTENSION),"\n";' > fred > > This is a bizarre behaviour. At a minimum the documentation should > actually state what the function does. Or do we bother to raise a patch to > fix this sort of thing, given that returning an empty string (or more > consistently with other functions, NULL) in this case could create a BC > break with existing buggy code? > This is weird, yes. It's not the lowest bit value that is returned, but the first element put in the array (as zend_hash_get_current_data() is used with no HashPosition) , which is even more confusing. How to explain that in the documentation ? :| Julien.Pauli --001a11c2c6749a109c04e5270f28--