com php-src: Improved performance of func_get_args() by eliminating useless copying: NEWS Zend/zend_bu iltin_functions.c
| From: | Dmitry Stogov | Date: | Mon, 28 Oct 2013 09:17:55 +0000 |
| Subject: | com php-src: Improved performance of func_get_args() by eliminating useless copying: NEWS Zend/zend_bu iltin_functions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73807@lists.php.net to get a copy of this message | ||
Commit: 91b8a6752e2d987ff7b1ee10c343dcba13c94914
Author: Dmitry Stogov <dmitry@zend.com> Mon, 28 Oct 2013 13:17:55 +0400
Parents: f8f643b4f71482be0e587c176ce4ffb2d6d2d92b
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=91b8a6752e2d987ff7b1ee10c343dcba13c94914
Log:
Improved performance of func_get_args() by eliminating useless copying
Changed paths:
M NEWS
M Zend/zend_builtin_functions.c
Diff:
diff --git a/NEWS b/NEWS
index b51b8b2..57066f9 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 1ad64e7..6cbe0bc 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);
}
}