Re: Ternary operator optimization tip

From: Date: Sun, 14 Dec 2008 19:59:38 +0000
Subject: Re: Ternary operator optimization tip
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-42258@lists.php.net to get a copy of this message
On Sun, Dec 14, 2008 at 8:06 PM, David Grudl <david@grudl.com> wrote: > Hello, > > ternary operator is very nice syntactic sugar... > > $foo = $cond ? $bar : $baz; > > ...but it may slows down scripts. When $bar is array or relative big string, > it is better to aviod sugar and use if: > > if ($cond) $foo = $bar; else $foo = $baz; > > and reference counting will be used. > > I don't know how difficult it is to implement, but it can be very useful > speed optimization for PHP 5.3 to improve ternary operator to use reference > counting. Do you have any numbers? -- Alexey Zakhlestin http://www.milkfarmsoft.com/

« previous php.internals (#42258) next »