On Wed, 14 Aug 2013, Anthony Ferrara wrote:
> Sebastian,
>
>
> On Wed, Aug 14, 2013 at 7:44 AM, Sebastian Krebs <krebs.seb@gmail.com>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