Sebastian,

On Wed, Aug 14, 2013 at 7:44 AM, Sebastian Krebs <krebs....@gmail.com>wrote:

> Hi,
>
> 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);
>
> ?
>

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.

Anthony

Reply via email to