summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2013-10-28 18:38:22 +0900
committerYasuo Ohgaki <yohgaki@php.net>2013-10-28 18:38:22 +0900
commit0db6adda48681fae147dfa952ce03e4ffc1b94c2 (patch)
treeeece42fd18ef882e7510312b97af8bacc5438531 /Zend/zend_builtin_functions.c
parent66fe7fabadd0b908828c865273d1fe3db2b7159b (diff)
parent91b8a6752e2d987ff7b1ee10c343dcba13c94914 (diff)
downloadphp-git-0db6adda48681fae147dfa952ce03e4ffc1b94c2.tar.gz
Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5
* 'PHP-5.5' of git.php.net:php-src: Improved performance of func_get_args() by eliminating useless copying Link to more readmes
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c15
1 files changed, 10 insertions, 5 deletions
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);
}
}