Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58958 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86097 invoked from network); 15 Mar 2012 14:42:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2012 14:42:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain l-i-e.com designates 67.139.134.202 as permitted sender) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:3004] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/C0-15833-6DFF16F4 for ; Thu, 15 Mar 2012 09:42:31 -0500 Received: (qmail 49249 invoked by uid 98); 15 Mar 2012 14:42:29 -0000 Received: from localhost by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.05 ( Clear:RC:1(127.0.0.1):. Processed in 0.037666 secs); 15 Mar 2012 14:42:29 -0000 Received: from localhost (HELO www.l-i-e.com) (127.0.0.1) by localhost with SMTP; 15 Mar 2012 14:42:29 -0000 Received: from webmail (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Thu, 15 Mar 2012 09:42:29 -0500 Message-ID: In-Reply-To: References: Date: Thu, 15 Mar 2012 09:42:29 -0500 To: "PHP Internals" User-Agent: SquirrelMail/1.4.21 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] Small question about performance From: ceo@l-i-e.com ("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 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. * > > > I'm curious about this. Can anyone confirm it or a benchmark should be > made? I don't see why your standard can't allow for: $a[$key] = someLong( functionCalls( hereThat( $spanOver85Chars ) ) ); Some folks insist that the closing parens be on separate lines. They're isomorphic to me, so I just put them on one line. So long as the count matches and they "line up" in reverse order, indented properly, it's all good. But then, I cut my teeth on Lisp, where a zillion parens to close off almost anything is the norm. :-) PS If you want a benchmark for how much 3 or 4 temporary zvals takes, knock yourself out. Also consider trying this in a second benchmark: //don't create / destroy zvals in the loop, hopefully $someLong = ''; $functionCalls = ''; $hereThat = ''; foreach ($a as $key => $value){ ... } PPS I'm assuming $a is not within the Coding Standard :-) -- brain cancer update: http://richardlynch.blogspot.com/search/label/brain%20tumor Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE