Req #42958 [Opn->Fbk]: [PATCH] Heredoc string constant folding

From: Date: Fri, 08 Apr 2011 19:14:49 +0000
Subject: Req #42958 [Opn->Fbk]: [PATCH] Heredoc string constant folding
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160051@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=42958&edit=1

 ID:                 42958
 Updated by:         jani@php.net
 Reported by:        gopalv@php.net
 Summary:            [PATCH] Heredoc string constant folding
-Status:             Open
+Status:             Feedback
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            Scripting Engine problem
 PHP Version:        5CVS-2007-10-13 (CVS)
 Block user comment: N
 Private report:     N

 New Comment:

Has this patch been applied yet..?


Previous Comments:
------------------------------------------------------------------------
[2007-10-13 22:04:35] gopalv@php.net

Find the patch/diff at

http://t3.dotgnu.info/code/zend_add_string.patch

------------------------------------------------------------------------
[2007-10-13 22:00:51] gopalv@php.net

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 this bug report at http://bugs.php.net/bug.php?id=42958&edit=1


Thread (5 messages)

« previous php.bugs (#160051) next »