Re: Referrences

From: Date: Mon, 03 Jun 2002 23:01:48 +0000
Subject: Re: Referrences
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-84827@lists.php.net to get a copy of this message
Markus Fischer wrote: > On Mon, Jun 03, 2002 at 10:29:19AM +0300, Michael Stolovitzsky wrote : >> If I understand correctly, given $bar is an object >> >> $foo = $bar >> >> will copy entire contents of $bar into foo. Following question: what >> happens with $foo = new Foo? Does the object get created, copied into >> $foo and then destroyed, while the copy in $foo lives? >> >> In other words, is there a performance benefit to do $foo =& new Foo? > > No, it's exactly the other way around with objects, you get a > slight performance penalty (though it may no be noticeable at > all). Mmmm.. how so? *wink wink*. Aren't referrences supposed to be faster than copying objects directly? Or did I understand you wrong? > > Currently, not useing the '&' operator will always create a > new (shallow) copy of the objects. ...right, so the copy operation on all properties (which might be big arrays) by assumption should take more overhead than a simple referrence to already allocated object. > > This is already addressed with the new Zend Engine 2 which > will behave as expected (objects aren't copied, they stay > atomic until explicitely duplicated [cloned]). > > - Markus > -- - Michael

« previous php.dev (#84827) next »