Re: Ternary operator performance improvements

From: Date: Mon, 17 Oct 2011 13:07:30 +0000
Subject: Re: Ternary operator performance improvements
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-55842@lists.php.net to get a copy of this message
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 <std_disclaimer.h>

« previous php.internals (#55842) next »