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 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php