Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13108 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62860 invoked by uid 1010); 2 Oct 2004 10:22:54 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62794 invoked from network); 2 Oct 2004 10:22:54 -0000 Received: from unknown (HELO jan.prima.de) (83.97.50.139) by pb1.pair.com with SMTP; 2 Oct 2004 10:22:54 -0000 Received: from BAUMBART (p508EACC5.dip.t-dialin.net [::ffff:80.142.172.197]) (IDENT: HydraIRC, AUTH: LOGIN tobi) by jan.prima.de with esmtp; Sat, 02 Oct 2004 10:22:53 +0000 Date: Sat, 2 Oct 2004 12:20:53 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <431687753.20041002122053@marcus-boerger.de> To: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Imrpvement for array functions From: mail@marcus-boerger.de (Marcus Boerger) 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