Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58962 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16521 invoked from network); 15 Mar 2012 16:28:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2012 16:28:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patrick.allaert@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:51574] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/00-16214-F98126F4 for ; Thu, 15 Mar 2012 11:28:15 -0500 Received: by werh12 with SMTP id h12so3568258wer.29 for ; Thu, 15 Mar 2012 09:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=oJhWx1B99MxLCoGG9yj6+X2z8hR0tv5F8y+6uV9L1uY=; b=lONkTNKNd6yZYX+xKiuFzF1SWd+chN9WolFjZDXOSMUz/YT1wqzmOZThKKvSfxe5XT 82lfgfD9JHF9NHwNdgBaHS0u2aDAzaoB2FlGUf6Jw3AHrU4X+aVUqe4+DLJKPH+XytgX fq7iF03TyiDHWBdnBDZHwoMJRlK4qNPjKI7b5N8qaMGLEUA6zZ514jd0QjV3Uzwvxpja 5Vo8SJU4BAtKOFaU4gaW0EVsDj0t4Ax6EM8gl8Z+cagbxPIvOqGmXCtDuagVLoRsOYf8 B9zGQG2cSPZ2eZYX5jeyd0irSx8tYEPaBUxxg9xwHgDFVgYfAGrfPBu0jrq46ZHjLGnR QWVw== MIME-Version: 1.0 Received: by 10.180.105.69 with SMTP id gk5mr32064869wib.3.1331828548078; Thu, 15 Mar 2012 09:22:28 -0700 (PDT) Sender: patrick.allaert@gmail.com Received: by 10.223.143.1 with HTTP; Thu, 15 Mar 2012 09:22:28 -0700 (PDT) In-Reply-To: References: Date: Thu, 15 Mar 2012 17:22:28 +0100 X-Google-Sender-Auth: 5RktSs8oiL8tdtk5GeWv7DDJQpI Message-ID: To: Nikita Popov Cc: Klaus Silveira , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Small question about performance From: patrickallaert@php.net (Patrick ALLAERT) 2012/3/15 Nikita Popov : > If I am understanding the text correctly it is saying that > =C2=A0 =C2=A0$f1 =3D f1(); > =C2=A0 =C2=A0$f2 =3D f2($f1); > =C2=A0 =C2=A0$f3 =3D f3($f2); > is using more memory than > =C2=A0 =C2=A0$f3 =3D 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. It does make sense to me. In the first case, when calling f3(), $f1 is still referenced. In the second case, when calling f3(), the result of f2() is referenced, but there is no more active reference to the result of f1(). Regarding the original problem: foreach($a as $key =3D> $val) { $a[$key] =3D someLong(functionCalls(hereThat($spanOver85Chars))); } Sounds easier to split over lines without temporary zvals: foreach($a as $key =3D> $val) { $a[$key] =3D someLong( functionCalls( hereThat( $spanOver85Chars ) ) ); }