Re: [PHP-DEV] Ternary operator associativity

2020-04-30 Thread Nikita Popov
On Thu, Apr 30, 2020 at 1:12 PM Ryan Jentzsch wrote: > Is there a possibility this can be fixed in version 8? From > http://phpsadness.com/sad/30 listed as an outright bug (I don't have > the C skills to fix this. I am just raising this as an issue that has > been a criticism of PHP for many year

[PHP-DEV] Ternary operator associativity

2020-04-30 Thread Ryan Jentzsch
Is there a possibility this can be fixed in version 8? From http://phpsadness.com/sad/30 listed as an outright bug (I don't have the C skills to fix this. I am just raising this as an issue that has been a criticism of PHP for many years now with a new major version upcoming that could allow for a

Re: [PHP-DEV] Ternary operator performance improvements

2011-10-18 Thread Stas Malyshev
Hi! On 10/18/11 2:43 PM, Alain Williams wrote: It probably does, but it is quite subtle. I was expecting the above to work since it does in C -- although in C&variable is an address which can be used in an expression ... the PHP '&' operator is different, in spite of apparent similarities. A

Re: [PHP-DEV] Ternary operator performance improvements

2011-10-18 Thread Alain Williams
On Tue, Oct 18, 2011 at 10:09:37PM +0200, Arnaud Le Blanc wrote: > Hi, > > Le Monday 17 October 2011 15:07:30, Alain Williams a écrit : > > 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 > >

Re: [PHP-DEV] Ternary operator performance improvements

2011-10-18 Thread Arnaud Le Blanc
Hi, Le Monday 17 October 2011 15:07:30, Alain Williams a écrit : > 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.

Re: [PHP-DEV] Ternary operator performance improvements

2011-10-17 Thread 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 v

Re: [PHP-DEV] Ternary operator performance improvements

2011-10-17 Thread Felipe Pena
2011/10/17 Ilia Alshanetsky : > Seems like a good patch, +1 from me on inclusion into 5.4/HEAD. > > On Fri, Oct 14, 2011 at 2:08 PM, 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

Re: [PHP-DEV] Ternary operator performance improvements

2011-10-17 Thread Ilia Alshanetsky
Seems like a good patch, +1 from me on inclusion into 5.4/HEAD. On Fri, Oct 14, 2011 at 2:08 PM, 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

[PHP-DEV] Ternary operator performance improvements

2011-10-14 Thread Arnaud Le Blanc
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: $

[PHP-DEV] ternary operator

2011-04-17 Thread G M
I should mention the more general use cases of the function I had made: ifset($arr, $key1, $key2, ..., $keyN, $default) actually, this function checks with array_key_exists, and not just isset. Meaning, if the value exists at that array key path and is null, it is used, otherwise, $default is u

Re: [PHP-DEV] Ternary operator optimization tip

2008-12-14 Thread Graham Kelly
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

Re: [PHP-DEV] Ternary operator optimization tip

2008-12-14 Thread Ólafur Waage
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

Re: [PHP-DEV] Ternary operator optimization tip

2008-12-14 Thread David Grudl
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

Re: [PHP-DEV] Ternary operator optimization tip

2008-12-14 Thread 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 need to be optimized. The only time you can really tel

Re: [PHP-DEV] Ternary operator optimization tip

2008-12-14 Thread Alexey Zakhlestin
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

[PHP-DEV] Ternary operator optimization tip

2008-12-14 Thread David Grudl
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 do