Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28956 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47891 invoked by uid 1010); 23 Apr 2007 14:59:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47875 invoked from network); 23 Apr 2007 14:59:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Apr 2007 14:59:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=dletz@blog.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dletz@blog.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain blog.de designates 87.230.13.215 as permitted sender) X-PHP-List-Original-Sender: dletz@blog.de X-Host-Fingerprint: 87.230.13.215 mail.blog.de Linux 2.5 (sometimes 2.4) (4) Received: from [87.230.13.215] ([87.230.13.215:37788] helo=www.mokono.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/D4-13231-3E9CC264 for ; Mon, 23 Apr 2007 10:59:49 -0400 Received: (qmail 29962 invoked from network); 23 Apr 2007 16:59:44 +0200 Received: from p54bd59fe.dip.t-dialin.net (HELO dominus.blog.de) (84.189.89.254) by mail.blog.de with SMTP; 23 Apr 2007 16:59:44 +0200 Date: Mon, 23 Apr 2007 16:58:59 +0200 To: internals@lists.php.net Organization: mokono GmbH Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Message-ID: User-Agent: Opera Mail/9.20 (Win32) Subject: Copy on write From: dletz@blog.de ("dletz@blog.de") Hello everyone in version the 5.2.1 i get strange results when using the reference = operator on arrays. When writing a function "a" with call by reference: function &a(&$anArray) { return $anArray; } and another function "b": function b($anArray) { return $anArray; } Then on my machine it takes much longer to call function "a" than to cal= l = function "b". Actually it seems that function "a" always copies the hole= = array wheter or not i write to it - while function "b" does not copy tha= t = array as long as i only read from it. But why does function "a" copy at all? Has anyone a explanation? Here is the benchmark code which shows the speed difference: Output on my machine: 5.2.1 test1 test2 0.0004 0.8020 0.0004 0.7862 0.0004 0.7970 0.0004 0.7752 0.0004 0.7783 0.0004 0.7797 0.0004 0.7834 0.0004 0.7806 0.0004 0.7747 0.0004 0.7777 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 0.0004 0.7835