com php-src: Avoid useless duplication: Zend/zend.c ext/spl/spl_array.c

From: Date: Fri, 19 Jan 2018 10:14:15 +0000
Subject: com php-src: Avoid useless duplication: Zend/zend.c ext/spl/spl_array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100962@lists.php.net to get a copy of this message
Commit: 5f349f3ab82965c2be784627e6ab2ed73093b708 Author: Dmitry Stogov <dmitry@zend.com> Fri, 19 Jan 2018 13:14:15 +0300 Parents: c2152a26621dd4b4bba3fe9183302c8a1fde9f2f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5f349f3ab82965c2be784627e6ab2ed73093b708 Log: Avoid useless duplication Changed paths: M Zend/zend.c M ext/spl/spl_array.c Diff: diff --git a/Zend/zend.c b/Zend/zend.c index ba84f84..f42a987 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -732,8 +732,9 @@ static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */ { zval globals; + /* IS_TYPE_COPYABLE, but with ref-counter 1 and not IS_TYPE_REFCOUNTED */ ZVAL_ARR(&globals, &EG(symbol_table)); - Z_TYPE_INFO_P(&globals) = IS_ARRAY; + Z_TYPE_FLAGS_P(&globals) = IS_TYPE_COPYABLE; ZVAL_NEW_REF(&globals, &globals); zend_hash_update(&EG(symbol_table), name, &globals); return 0; diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index f98f111..01001f2 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1118,9 +1118,13 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar } if (Z_TYPE_P(array) == IS_ARRAY) { - //??? TODO: try to avoid array duplication zval_ptr_dtor(&intern->array); - ZVAL_DUP(&intern->array, array); + if (Z_REFCOUNT_P(array) == 1) { + ZVAL_COPY(&intern->array, array); + } else { + //??? TODO: try to avoid array duplication + ZVAL_ARR(&intern->array, zend_array_dup(Z_ARR_P(array))); + } } else { if (Z_OBJ_HT_P(array) == &spl_handler_ArrayObject || Z_OBJ_HT_P(array) == &spl_handler_ArrayIterator) { zval_ptr_dtor(&intern->array);

« previous php.cvs (#100962) next »