RE: [PEAR-DEV] Package proposal: Mail_Mime (alternative)

From: Date: Fri, 15 Aug 2003 16:20:29 +0000
Subject: RE: [PEAR-DEV] Package proposal: Mail_Mime (alternative)
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-19826@lists.php.net to get a copy of this message
> From: Heino H. Gehlsen [mailto:heino@gehlsen.dk] > Sent: Friday, August 15, 2003 5:50 PM > > > > in the hope of improvements I have done a lot of parsing by reference > internally. > > > > Oh bad move. > > > > Pass by reference is slower in PHP4. PHP4 has reference counting which > > prevent copies from being made if the variable is not actually modified. > > > > $foo = 'foo'; ('foo' in memory, ref counter 1) > > $foo = $bar; ('foo' in memory, ref counter 2) > > $bar = 'bar' ('foo' and 'bar' in memory, each with ref > > counter 1) > > Ehh... I don't see an parsing by reference (not &'s) in your example... doh! I made a mistake in the second line $foo = 'foo'; ('foo' in memory, ref counter 1) $bar = $foo; ('foo' in memory, ref counter 2) $bar = 'bar' ('foo' and 'bar' in memory, each with ref counter 1) the point is that in the second line you don't actually make a copy yet. Only once you change the value a new var is really created the same applies to passing values to a function. Because if this mechanism pass by reference is actually slower than not using it. Therefore pass by reference should only be used if you really need it. Regards, Lukas

« previous php.pear.dev (#19826) next »