Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13162 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58600 invoked by uid 1010); 5 Oct 2004 01:07:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 58565 invoked from network); 5 Oct 2004 01:07:02 -0000 Received: from unknown (HELO mail.zend.com) (80.74.107.235) by pb1.pair.com with SMTP; 5 Oct 2004 01:07:02 -0000 Received: (qmail 29678 invoked from network); 5 Oct 2004 01:07:00 -0000 Received: from localhost (HELO AndiNotebook.zend.com) (127.0.0.1) by localhost with SMTP; 5 Oct 2004 01:07:00 -0000 Message-ID: <5.1.0.14.2.20041004180452.0441b350@localhost> X-Sender: andi@localhost X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Mon, 04 Oct 2004 18:06:57 -0700 To: Marcus Boerger ,internals@lists.php.net In-Reply-To: <431687753.20041002122053@marcus-boerger.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Improvement for array functions From: andi@zend.com (Andi Gutmans) References: <431687753.20041002122053@marcus-boerger.de> Marcus, From reading this it doesn't seem as if this patch is array() specific but is a general one. If I understand correctly, it will pass the hash (zval *) as-is and will never do a zval_copy_ctor(). This means that this value must for all practical purposes be read-only. What does this mean to the extension writer? Am I correct? We need to be sure that we don't add this new functionality without being sure how the extensions should handle it in order not to get side effects. Andi At 12:20 PM 10/2/2004 +0200, Marcus Boerger wrote: >Hello internals, > >Hello Andi, > > here's another major speed improvement for array functions which >is probably also valid for other functions, too. The point is that >we have several functions not forcing parameters by reference because >they not only accept variables but also parameters by value and we >cannot pass values by ref directly. The solution is to automatically >find out whether to pass by ref or not. See the test script for >the difference - it's amazing in this example! > >http://php.net/~helly/php/ext/ze2/ze2-auto-ref-20040930.diff.txt >http://php.net/~helly/php/ext/ze2/ze2-auto-ref.php > >How does it work exactly: > >For example the function in_array() is defined with both arg types == 0 >which mean not by ref. As a consequence when you have an array which is >stored somewhere else as a reference it will be copied. So the obvious >question is why not declare the function arg type as force by reference? >Simply because that does not work. The array functions are all designed >to accept arrays on the fly like in_array(2,array(1,2)). And unfortunatley >those direct values cannot be send by reference. But the compiler knows >whether it can send by ref or not and that is what the patch does. It >adds a new argument infor which tells the compiler to find out whether >the parameter can be passed by reference or must be passed by value. > >Any comments? > >-- >Best regards, > Marcus > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php