Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56188 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99265 invoked from network); 9 Nov 2011 11:51:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Nov 2011 11:51:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=koubel@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=koubel@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 213.151.94.173 as permitted sender) X-PHP-List-Original-Sender: koubel@php.net X-Host-Fingerprint: 213.151.94.173 pelikan.iinfo.cz Received: from [213.151.94.173] ([213.151.94.173:52262] helo=stana.iinfo.cz) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/60-30740-B296ABE4 for ; Wed, 09 Nov 2011 06:51:08 -0500 Received: from pc-kubelik.iinfo.local ([213.151.94.189]) (authenticated user miroslav.kubelik@iinfo.cz) by stana.iinfo.cz (Kerio Connect 7.2.3 patch 1) (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for internals@lists.php.net; Wed, 9 Nov 2011 12:51:03 +0100 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net Date: Wed, 09 Nov 2011 12:51:03 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: User-Agent: Opera Mail/11.52 (Win32) Subject: Re: Ternary operator performance improvements From: koubel@php.net (=?utf-8?Q?Miroslav_Kubel=C3=ADk?=) 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