summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--Zend/zend_builtin_functions.c15
2 files changed, 12 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index b51b8b23eb..57066f9796 100644
--- a/NEWS
+++ b/NEWS
@@ -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);
}
}