diff options
author | Dmitry Stogov <dmitry@zend.com> | 2013-10-28 13:17:55 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2013-10-28 13:17:55 +0400 |
commit | 91b8a6752e2d987ff7b1ee10c343dcba13c94914 (patch) | |
tree | dc3f7ed9f599c061cabedbd1d4da5537e4a6cdca | |
parent | f8f643b4f71482be0e587c176ce4ffb2d6d2d92b (diff) | |
download | php-git-91b8a6752e2d987ff7b1ee10c343dcba13c94914.tar.gz |
Improved performance of func_get_args() by eliminating useless copying
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | Zend/zend_builtin_functions.c | 15 |
2 files changed, 12 insertions, 5 deletions
@@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2013, PHP 5.5.6 - Core: + . Improved performance of func_get_args by eliminating useless copying. + (Dmitry) . Fixed bug #65939 (Space before ";" breaks php.ini parsing). (brainstorm at nopcode dot org) . Fixed bug #65911 (scope resolution operator - strange behavior with $this). diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 1ad64e74ea..6cbe0bc687 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -461,12 +461,17 @@ ZEND_FUNCTION(func_get_args) array_init_size(return_value, arg_count); for (i=0; i<arg_count; i++) { - zval *element; + zval *element, *arg; - ALLOC_ZVAL(element); - *element = **((zval **) (p-(arg_count-i))); - zval_copy_ctor(element); - INIT_PZVAL(element); + arg = *((zval **) (p-(arg_count-i))); + if (!Z_ISREF_P(arg)) { + element = arg; + Z_ADDREF_P(element); + } else { + ALLOC_ZVAL(element); + INIT_PZVAL_COPY(element, arg); + zval_copy_ctor(element); + } zend_hash_next_index_insert(return_value->value.ht, &element, sizeof(zval *), NULL); } } |