Improved performance of func_get_args() by eliminating useless copying

This commit is contained in:
Dmitry Stogov 2013-10-28 13:17:55 +04:00
parent f8f643b4f7
commit 91b8a6752e
2 changed files with 12 additions and 5 deletions

2
NEWS
View File

@ -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).

View File

@ -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);
}
}