Hi,
I wouldn't really worry about the ternary operator too much. These kinds of
micro optimizations really only appear to make a difference in contrived
benchmarks and usually aren't the norm in real life applications. However,
with that said, an optimization is an optimization. Optimizations like
Time:
$arr = range(0, 100); // 0.6367609500885
$foo == true ? $foo = $arr : NULL; // 3.0994415283203E-06
if (true) $foo = $arr; else $foo = NULL; // 2.8610229492188E-06
PHP 5.1.6
Olafur Waage
On Sun, Dec 14, 2008 at 9:30 PM, David Grudl wrote:
>
> Původní zpráva
> Od: Ilia
Původní zpráva
Od: Ilia Alshanetsky
While it is slower due to the use of temp vars, in my experience
unless you have a few hundred operations involving ternary operator
you cannot even see the difference. Even then there are typically way
more important areas of code that ne
While it is slower due to the use of temp vars, in my experience
unless you have a few hundred operations involving ternary operator
you cannot even see the difference. Even then there are typically way
more important areas of code that need to be optimized. The only time
you can really tel
On Sun, Dec 14, 2008 at 8:06 PM, David Grudl 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 = $ba