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
Hi Miroslav & Arnaud,
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 it the same with: $content = file_get_contents('…') ?: ''; Maybe we
could have a heuristic for this shortcut operator no?
Best regards.
--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/
PhD. student at LIFC/DISC (Vesontio) and INRIA (Cassis)
http://lifc.univ-fcomte.fr/ and http://www.inria.fr/
Member of HTML and WebApps Working Group of W3C
http://w3.org/
Hi Miroslav!
Yes, the ternary patch fixes that problem too :)
Nikita
2011/11/9 Miroslav Kubelík koubel@php.net:
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
On Wed, 09 Nov 2011 16:24:33 +0100, Nikita Popov
nikita.ppv@googlemail.com wrote:
Hi Miroslav!
Yes, the ternary patch fixes that problem too :)
Nikita
Nice, thank all participants very much, Arnaud especially, very helpful
patch.
Maybe string case can be mentioned in the Zend/micro_bench.php as array
micro benchmars are:
https://github.com/php/php-src/commit/8bdb7a0a5c5466aec576c13f3af9c1a6cacdb35c#diff-1
Miroslav Kubelík