Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55861 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95173 invoked from network); 18 Oct 2011 20:09:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Oct 2011 20:09:42 -0000 Authentication-Results: pb1.pair.com header.from=arnaud.lb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=arnaud.lb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: arnaud.lb@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:41579] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/55-46813-50DDD9E4 for ; Tue, 18 Oct 2011 16:09:41 -0400 Received: by wyf23 with SMTP id 23so1084537wyf.29 for ; Tue, 18 Oct 2011 13:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; bh=9f0tNmskqnRup3N2A5ecj08W1DcwOi2xhWUsWiHcKu0=; b=F2zPhp2x8TFus2a2GjZaodLeXl1waG9gyfy07MH/BeZnOQuX/QwM0q3ZS77X1LhfGv tjq1BMZezHBe+Wv3na9pOE6tKA2/jcDZJifTDsaEhteXC2wne26mitwEdSsesyRyOZNc wbudWWB/If15q3OLlDv/ffgCYGfo3KjIe+bgA= Received: by 10.227.72.148 with SMTP id m20mr1416830wbj.11.1318968577905; Tue, 18 Oct 2011 13:09:37 -0700 (PDT) Received: from noch2.localnet (130-244-168-88.selfip.net. [88.168.244.130]) by mx.google.com with ESMTPS id fo7sm5528304wbb.20.2011.10.18.13.09.36 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Oct 2011 13:09:36 -0700 (PDT) To: internals@lists.php.net Date: Tue, 18 Oct 2011 22:09:37 +0200 User-Agent: KMail/1.13.7 (Linux/3.0.0-1-amd64; KDE/4.6.5; x86_64; ; ) Cc: Alain Williams References: <201110142008.56344.arnaud.lb@gmail.com> <20111017130730.GA27102@phcomp.co.uk> In-Reply-To: <20111017130730.GA27102@phcomp.co.uk> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-ID: <201110182209.37210.arnaud.lb@gmail.com> Subject: Re: [PHP-DEV] Ternary operator performance improvements From: arnaud.lb@gmail.com (Arnaud Le Blanc) Hi, Le Monday 17 October 2011 15:07:30, Alain Williams a =E9crit : > On Fri, Oct 14, 2011 at 08:08:56PM +0200, Arnaud Le Blanc wrote: > > Hi, > >=20 > > 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. > >=20 > > The ternary operator always copies its second or third operand, which is > > very >=20 > > slow compared to an if/else when the operand is an array for example: > Is that why the following does not work as I expected: >=20 > $dbh =3D $how =3D=3D 'r' ? (&$dbh_r) : (&$dbh_w); >=20 > $dbh is NOT a reference to $dbh_r or $dbh_w. This is expected;=20 http://docs.php.net/manual/en/language.operators.comparison.php explains it: > Please note that the ternary operator is a statement, and that it doesn't= =20 evaluate to a variable, but to the result of a statement. This is why you can't assign the result of the ternary operator by referenc= e.=20 The patch doesn't change this. Best regards,