From d9dd1b9e144749e9563c789d89297fefc173766b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 11 Apr 2008 09:43:28 +0000 Subject: Optimized ZEND_RETURN opcode to not allocate and copy return value if it is not used. --- Zend/zend_execute_API.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Zend/zend_execute_API.c') diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 98b17376cd..74ffc1c56c 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1273,7 +1273,7 @@ ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSR Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0'; } else { Z_STRLEN(pv) = strlen(str); - Z_STRVAL(pv) = estrndup(str, Z_STRLEN(pv)); + Z_STRVAL(pv) = str; } Z_TYPE(pv) = IS_STRING; @@ -1317,7 +1317,9 @@ ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSR } else { retval = FAILURE; } - zval_dtor(&pv); + if (retval_ptr) { + zval_dtor(&pv); + } return retval; } /* }}} */ @@ -1339,7 +1341,6 @@ void execute_new_code(TSRMLS_D) /* {{{ */ { zend_op *opline, *end; zend_op *ret_opline; - zval *local_retval=NULL; if (!(CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) || CG(active_op_array)->backpatch_count>0 @@ -1393,12 +1394,9 @@ void execute_new_code(TSRMLS_D) /* {{{ */ zend_release_labels(TSRMLS_C); - EG(return_value_ptr_ptr) = &local_retval; + EG(return_value_ptr_ptr) = NULL; EG(active_op_array) = CG(active_op_array); zend_execute(CG(active_op_array) TSRMLS_CC); - if (local_retval) { - zval_ptr_dtor(&local_retval); - } if (EG(exception)) { zend_exception_error(EG(exception) TSRMLS_CC); -- cgit v1.2.1