Re: Ternary operator performance improvements
| From: | Miroslav Kubelík | Date: | Wed, 09 Nov 2011 11:51:03 +0000 |
| Subject: | Re: Ternary operator performance improvements | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-56188@lists.php.net to get a copy of this message | ||
On 10/14/2011 10: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 always copies its second or third operand, which is very slow compared to an if/else when the operand is an array for example: ...Same "copy always" behavior is made with string in ternary operator, and it can be also very annoying e.g: $content = file_get_contents('http://www.w3.org/TR/2011/WD-html-markup-20110525/spec.html'); $test = $content !== false ? $content : ''; Is this case also solved with your patch or huge strings are still problem with a ternary "copy always" functionality? Maybe it's more rare case then array. P.S: Sorry I don't test it directly with beta2, I have no place to test. M. Kubelik