Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58966 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40970 invoked from network); 15 Mar 2012 17:39:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2012 17:39:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=dragoonis@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dragoonis@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: dragoonis@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:64025] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 68/55-16214-739226F4 for ; Thu, 15 Mar 2012 12:39:05 -0500 Received: by lahl5 with SMTP id l5so2897717lah.29 for ; Thu, 15 Mar 2012 10:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=wFbajWrtjoIg/ZOTOo5m7/jByVVqGivKnMUhMGi/h3A=; b=jcZTIhF49eukRxYnn4lNZGWEn71BDc7LvbobhZta4gLNnNVF870EspXpNhpYu4vhe7 5NmKHcX2nMlteDRsJvJlQTvFmrtiExPGTLBUkcI2UMWqY+hCp+vaWS6PXum2EBXzj2TT JCeNJ3QhwOOUc0A0yierrMrLKFnYW/X4WvEqnuzMm7M5QT3uHoDvEvhdB+VcrZUp60Ol x8zSRqxxiyTOCt72QkULeW2H8xZGiE96dT9aRlw7ephzoYgKmEhvNwa3Ow401Nmm2XLc CzdB/xY+/JzomuSSM05zv5CBBmzAmefSoKj9HX/ViODB4G5byz6Quh5KrmR7+mfwcapT 1oFw== MIME-Version: 1.0 Received: by 10.112.36.167 with SMTP id r7mr2823964lbj.32.1331833140195; Thu, 15 Mar 2012 10:39:00 -0700 (PDT) Received: by 10.152.13.40 with HTTP; Thu, 15 Mar 2012 10:39:00 -0700 (PDT) In-Reply-To: References: Date: Thu, 15 Mar 2012 17:39:00 +0000 Message-ID: To: Nikita Popov Cc: Patrick ALLAERT , Klaus Silveira , PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Small question about performance From: dragoonis@gmail.com (Paul Dragoonis) On Thu, Mar 15, 2012 at 4:54 PM, Nikita Popov w= rote: > 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 >>> =A0 =A0$f1 =3D f1(); >>> =A0 =A0$f2 =3D f2($f1); >>> =A0 =A0$f3 =3D f3($f2); >>> is using more memory than >>> =A0 =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(). > 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. > > If that is not true, then forget whatever I said. > > But if it is true, then there is no inherent difference between the > two version. The only difference is that explicit $variables would > need an entry in the active symbol table, which is pretty much > negligible. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >