Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68516 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36381 invoked from network); 14 Aug 2013 13:26:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2013 13:26:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:47996] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/75-06453-7658B025 for ; Wed, 14 Aug 2013 09:25:59 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id F3FB2E2029; Wed, 14 Aug 2013 14:25:56 +0100 (BST) Date: Wed, 14 Aug 2013 14:25:56 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Anthony Ferrara cc: Sebastian Krebs , Stas Malyshev , Julien Pauli , "internals@lists.php.net" In-Reply-To: Message-ID: References: <520B4772.8090701@sugarcrm.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] [RFC] Constant Scalar Expressions From: derick@php.net (Derick Rethans) On Wed, 14 Aug 2013, Anthony Ferrara wrote: > Sebastian, > > > On Wed, Aug 14, 2013 at 7:44 AM, Sebastian Krebs wrote: > > > Just asking: Does this cover only declarations, or every constant > > expression, for example > > > > $weeks = $secs / (60 * 60 * 24 * 7); > > > > becomes to the opcode-equivalent of > > > > $weeks = $secs / (604800); A week isn't always 7 * 24 hours... > Currently, only places that use the static_scalar parser definition will > use this: http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y#945 > > So today that's constants (using const keyword), class constants, class > properties, function parameter values and declare statements. > > To do the other part would likely need to happen in the compiler itself > (look for all opcodes of type _SPEC_CONST_CONST, and then optimize those > away). I will experiment a bit, but my gut tells me it will result in a lot > of parser or compiler complexity to attempt to do that (for which there > will be so little gain, as the runtime performance is already quite > fast)... At which point the complexity isn't worth it. Perhaps something for OpCache's optimizer though, if it doesn't already do that... cheers, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine