Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Reindl Harald
thanks exactly what i assumed, but better to be sure instead wasting somewhere ressources without need :-) Am 15.03.2012 20:10, schrieb Michael Stowe: > The $b on this example would be freed as it is in the function's scope, and > not the global scope. The exception to this would be a static var

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Michael Stowe
The $b on this example would be freed as it is in the function's scope, and not the global scope. The exception to this would be a static variable within a function, which would persist for future use within the function. Class properties on the other hand will persist until the object is destruc

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Reindl Harald
Am 15.03.2012 18:41, schrieb Paul Dragoonis: >>> I don't really know when PHP frees temporary variables, but my guess >>> was that they are freed when the scope is left. >> >> Each variable has a refcount, then that hits 0 it can be freed up. > > To add to that. A zval will have a refcount, so i

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Paul Dragoonis
On Thu, Mar 15, 2012 at 5:39 PM, Paul Dragoonis wrote: > On Thu, Mar 15, 2012 at 4:54 PM, Nikita Popov > wrote: >> On Thu, Mar 15, 2012 at 5:22 PM, Patrick ALLAERT >> wrote: >>> 2012/3/15 Nikita Popov : If I am understanding the text correctly it is saying that    $f1 = f1();  

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Paul Dragoonis
On Thu, Mar 15, 2012 at 4:54 PM, Nikita Popov wrote: > On Thu, Mar 15, 2012 at 5:22 PM, Patrick ALLAERT > wrote: >> 2012/3/15 Nikita Popov : >>> If I am understanding the text correctly it is saying that >>>    $f1 = f1(); >>>    $f2 = f2($f1); >>>    $f3 = f3($f2); >>> is using more memory than

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Nikita Popov
On Thu, Mar 15, 2012 at 5:22 PM, Patrick ALLAERT wrote: > 2012/3/15 Nikita Popov : >> If I am understanding the text correctly it is saying that >>    $f1 = f1(); >>    $f2 = f2($f1); >>    $f3 = f3($f2); >> is using more memory than >>    $f3 = f3(f2(f1())); >> >> For me this doesn't make any sen

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Stas Malyshev
Hi! If I am understanding the text correctly it is saying that $f1 = f1(); $f2 = f2($f1); $f3 = f3($f2); is using more memory than $f3 = f3(f2(f1())); Short answer: it doesn't matter, use either as you wish. Long answer: Technically, the former also uses hash buckets to bi

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Michael Stowe
Just to elaborate on what Patrick said, in the first case the variables are temporary, where in the second they persist even after you finish your loop. So even after the foreach is finished, the $f1, $f2, and $f3 variables are still storing data- even though it is no longer needed. In order to f

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Patrick ALLAERT
2012/3/15 Nikita Popov : > If I am understanding the text correctly it is saying that >    $f1 = f1(); >    $f2 = f2($f1); >    $f3 = f3($f2); > is using more memory than >    $f3 = f3(f2(f1())); > > For me this doesn't make any sense. In the latter case PHP will also > create temporary variables t

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Nikita Popov
On Thu, Mar 15, 2012 at 3:21 PM, Klaus Silveira wrote: > Hello internals, > > I've been involved in a discussion at the PHP Standards Group and we > recently had the following statement: > > *Say you had a loop, and inside that loop you wanted to modify a param >> **update the key:** >> **foreach(

Re: [PHP-DEV] Small question about performance

2012-03-15 Thread Richard Lynch
On Thu, March 15, 2012 9:21 am, Klaus Silveira wrote: > Hello internals, > > I've been involved in a discussion at the PHP Standards Group and we > recently had the following statement: > > *Say you had a loop, and inside that loop you wanted to modify a param >> **update the key:** >> **foreach($a

[PHP-DEV] Small question about performance

2012-03-15 Thread Klaus Silveira
Hello internals, I've been involved in a discussion at the PHP Standards Group and we recently had the following statement: *Say you had a loop, and inside that loop you wanted to modify a param > **update the key:** > **foreach($a as $key => $val) { > ** $a[$key] = someLong(functionCalls(hereT