Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56191 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11725 invoked from network); 9 Nov 2011 13:52:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Nov 2011 13:52:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 87.106.212.190 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 87.106.212.190 s15355703.onlinehome-server.info Linux 2.6 Received: from [87.106.212.190] ([87.106.212.190:46815] helo=s15355703.onlinehome-server.info) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/51-01735-E858ABE4 for ; Wed, 09 Nov 2011 08:52:14 -0500 Received: from Hwhost2.local (unknown [134.157.87.223]) by s15355703.onlinehome-server.info (Postfix) with ESMTPA id 28873E40A6; Wed, 9 Nov 2011 14:51:43 +0100 (CET) Message-ID: <4EBA858B.10103@hoa-project.net> Date: Wed, 09 Nov 2011 14:52:11 +0100 Reply-To: ivan.enderlin@hoa-project.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: =?UTF-8?B?TWlyb3NsYXYgS3ViZWzDrWs=?= CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: Ternary operator performance improvements From: ivan.enderlin@hoa-project.net ("Ivan Enderlin @ Hoa") Hi Miroslav & Arnaud, On 09/11/11 12:51, Miroslav Kubel=C3=ADk wrote: > 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=20 >> 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, an= d > it can be > also very annoying e.g: > > $content =3D > file_get_contents('http://www.w3.org/TR/2011/WD-html-markup-20110525/sp= ec.html');=20 > > $test =3D $content !=3D=3D false ? $content : ''; Is it the same with: $content =3D file_get_contents('=E2=80=A6') ?: ''; M= aybe we=20 could have a heuristic for this shortcut operator no? Best regards. --=20 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/