Re: Small question about performance

From: Date: Thu, 15 Mar 2012 14:57:41 +0000
Subject: Re: Small question about performance
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Thu, Mar 15, 2012 at 3:21 PM, Klaus Silveira <[email protected]> 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 as $key => $val) {
>> **   $a[$key] = someLong(functionCalls(hereThat($spanOver85Chars)));
>> **}**
>> **If this exceeded the line width, you would have to split things like
>> **this over a few lines, storing the val temporarily in a zval's until
>> **you reached your end computation. Therefore allocating more memory
>> **iteratively. *
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 to store the return values. There should be
no difference in memory consumption.

Nikita


Thread (12 messages)

« previous php.internals (#58959) next »