Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55842 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22200 invoked from network); 17 Oct 2011 13:07:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2011 13:07:39 -0000 Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Linux 2.6 Received: from [78.32.209.33] ([78.32.209.33:61451] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/A4-27630-6982C9E4 for ; Mon, 17 Oct 2011 09:07:38 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.63) (envelope-from ) id 1RFmug-00074D-Qq for internals@lists.php.net; Mon, 17 Oct 2011 14:07:30 +0100 Date: Mon, 17 Oct 2011 14:07:30 +0100 Cc: PHP Internals Message-ID: <20111017130730.GA27102@phcomp.co.uk> References: <201110142008.56344.arnaud.lb@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201110142008.56344.arnaud.lb@gmail.com> User-Agent: Mutt/1.4.2.2i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] Ternary operator performance improvements From: addw@phcomp.co.uk (Alain Williams) On Fri, Oct 14, 2011 at 08:08:56PM +0200, Arnaud Le Blanc wrote: > Hi, > > I've already posted this patch and it has since been reviewed and improved. > I'm re-posting it for discussion before eventually commiting it. > > The ternary operator always copies its second or third operand, which is very > slow compared to an if/else when the operand is an array for example: Is that why the following does not work as I expected: $dbh = $how == 'r' ? (&$dbh_r) : (&$dbh_w); $dbh is NOT a reference to $dbh_r or $dbh_w. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include