From:             [EMAIL PROTECTED]
Operating system: 
PHP version:      5CVS-2007-10-13 (CVS)
PHP Bug Type:     Feature/Change Request
Bug description:  [PATCH] Heredoc string constant folding

Description:
------------
Heredocs in php generates too many opcodes.

The tokenizer seems to be hooked directly into the zend_do_add_string() 
call which creates a new opcode irrespective of previous opcode, where it
could do better to just check whether data can be piggy-backed onto the
previous opcode. 

Reproduce code:
---------------
<?php 
echo <<<EOF
foo bar is right
EOF;
?>

php52 -dvld.active heredoc.php


Expected result:
----------------
filename:       /tmp/heredoc.php
function name:  (null)
number of ops:  5
line     #  op                           fetch          ext  operands
-------------------------------------------------------------------------------
   4     0  INIT_STRING                                      ~0
         1  ADD_STRING                                       ~0, ~0,
'heredocs+are+fubar'
   5     2  ECHO                                                 ~0
   7     3  RETURN                                               1
         4  ZEND_HANDLE_EXCEPTION        


Actual result:
--------------
filename:       /tmp/heredoc.php
function name:  (null)
number of ops:  10
line     #  op                           fetch          ext  operands
-------------------------------------------------------------------------------
   4     0  INIT_STRING                                      ~0
         1  ADD_STRING                                       ~0, ~0,
'heredocs'
         2  ADD_STRING                                       ~0, ~0, '+'
         3  ADD_STRING                                       ~0, ~0,
'are'
         4  ADD_STRING                                       ~0, ~0, '+'
         5  ADD_STRING                                       ~0, ~0,
'fubar'
   5     6  ADD_STRING                                       ~0, ~0, ''
         7  ECHO                                                 ~0
   7     8  RETURN                                               1
         9  ZEND_HANDLE_EXCEPTION                                


-- 
Edit bug report at http://bugs.php.net/?id=42958&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42958&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42958&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42958&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42958&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42958&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42958&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42958&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42958&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42958&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42958&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42958&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42958&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42958&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42958&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42958&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42958&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42958&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42958&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42958&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42958&r=mysqlcfg

Reply via email to