From: Dmitry Stogov Date: Fri, 30 May 2014 10:40:19 +0000 (+0400) Subject: Improved conditions order X-Git-Tag: POST_PHPNG_MERGE~235 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=032bdbba735d1def5e305b1d486604e5f215617a;p=php Improved conditions order --- diff --git a/Zend/zend.h b/Zend/zend.h index 1a4d301f45..1e592c05c1 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -727,8 +727,11 @@ END_EXTERN_C() #define SEPARATE_ZVAL(zv) do { \ zval *_zv = (zv); \ - if (Z_REFCOUNTED_P(_zv)) { \ - if (Z_REFCOUNT_P(_zv) > 1) { \ + if (Z_REFCOUNTED_P(_zv) || \ + Z_IMMUTABLE_P(_zv)) { \ + if (Z_IMMUTABLE_P(_zv)) { \ + zval_copy_ctor_func(_zv); \ + } else if (Z_REFCOUNT_P(_zv) > 1) { \ if (Z_ISREF_P(_zv)) { \ Z_DELREF_P(_zv); \ ZVAL_DUP(_zv, Z_REFVAL_P(_zv)); \ @@ -737,20 +740,20 @@ END_EXTERN_C() zval_copy_ctor_func(_zv); \ } \ } \ - } else if (Z_IMMUTABLE_P(_zv)) { \ - zval_copy_ctor_func(_zv); \ } \ } while (0) #define SEPARATE_ZVAL_IF_NOT_REF(zv) do { \ zval *_zv = (zv); \ if (!Z_ISREF_P(_zv)) { \ - if (Z_COPYABLE_P(_zv) && \ - Z_REFCOUNT_P(_zv) > 1) { \ - Z_DELREF_P(_zv); \ - zval_copy_ctor_func(_zv); \ - } else if (Z_IMMUTABLE_P(_zv)) { \ - zval_copy_ctor_func(_zv); \ + if (Z_COPYABLE_P(_zv) || \ + Z_IMMUTABLE_P(_zv)) { \ + if (Z_IMMUTABLE_P(_zv)) { \ + zval_copy_ctor_func(_zv); \ + } else if (Z_REFCOUNT_P(_zv) > 1) { \ + Z_DELREF_P(_zv); \ + zval_copy_ctor_func(_zv); \ + } \ } \ } \ } while (0) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 0cfd8f456c..b3b7c0a001 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1122,11 +1122,7 @@ static zend_always_inline void zend_fetch_dimension_address(zval *result, zval * ZVAL_DEREF(container); if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { - if (Z_IMMUTABLE_P(container)) { - zval_copy_ctor(container); - } else if (container == container_ptr) { - SEPARATE_ZVAL(container); - } + SEPARATE_ZVAL(container); fetch_from_array: if (dim == NULL) { retval = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));