Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58965 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28289 invoked from network); 15 Mar 2012 16:54:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2012 16:54:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:43320] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/A2-16214-9BE126F4 for ; Thu, 15 Mar 2012 11:54:18 -0500 Received: by lahl5 with SMTP id l5so2856300lah.29 for ; Thu, 15 Mar 2012 09:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=M7rCDKWLSrFxWnvQw7jbdJvA4IM3Z8Z5HPArQlKuCvc=; b=K/bvqPYcfE9UTXO5t12y0eiuaQTaUjoXbMfz74lf+QUAHKHrRylZwaQGZeJ1LDm7Qx ZTk+mymZNMsnBNvYgJkv00cVqclzlXz59VGXw9EIw0LUN9Bj6Ju2TEao5LKs771a+IbG wPMlw0xGvrJh2U9awCjwTKTnHKVjdqA6KeHgtP769z5LL/DAi0ndLeAy9gz1YKYbGkd3 2uf7xt7QQGuN9pAeU80tmMx9PdbMm4T2T2D1zfcIQnXMNYAJLFLfSU3byVZQWKH38kW0 Jc9NROZnZIhQp4HYLtI1yexJ3CAOQZbKPZT0hg6fi3O5kFhN1mX5ZuAddHJjd0yNx734 ft+g== MIME-Version: 1.0 Received: by 10.112.9.225 with SMTP id d1mr1917027lbb.10.1331830454959; Thu, 15 Mar 2012 09:54:14 -0700 (PDT) Received: by 10.152.127.68 with HTTP; Thu, 15 Mar 2012 09:54:14 -0700 (PDT) In-Reply-To: References: Date: Thu, 15 Mar 2012 17:54:14 +0100 Message-ID: To: Patrick ALLAERT Cc: 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: nikita.ppv@googlemail.com (Nikita Popov) On Thu, Mar 15, 2012 at 5:22 PM, Patrick ALLAERT w= rote: > 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. 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.