]> granicus.if.org Git - php/commitdiff
micro-optimization
authorDmitry Stogov <dmitry@zend.com>
Fri, 5 Jun 2020 11:20:39 +0000 (14:20 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 5 Jun 2020 11:20:39 +0000 (14:20 +0300)
Zend/zend_execute.c
Zend/zend_execute.h

index 11e1904461cd9b58afcf0c2a2f3c123f3e168452..6a56dfdb1e14a7707a4481e40b337e3b22682e61 100644 (file)
@@ -3109,10 +3109,17 @@ static zend_always_inline void i_zval_ptr_dtor_noref(zval *zval_ptr) {
        }
 }
 
-ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, zend_uchar value_type, zend_bool strict, zend_refcounted *ref)
+ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, zend_uchar value_type, zend_bool strict)
 {
        zend_bool ret;
        zval value;
+       zend_refcounted *ref = NULL;
+
+       if (Z_ISREF_P(orig_value)) {
+               ref = Z_COUNTED_P(orig_value);
+               orig_value = Z_REFVAL_P(orig_value);
+       }
+
        ZVAL_COPY(&value, orig_value);
        ret = zend_verify_ref_assignable_zval(Z_REF_P(variable_ptr), &value, strict);
        variable_ptr = Z_REFVAL_P(variable_ptr);
index 2299adf62fe7ee4832e0e865fb8863137538ebac..58e1bbc2a9ef3d27b5e613569f013f399aabfdd0 100644 (file)
@@ -86,10 +86,17 @@ ZEND_API zend_bool zend_value_instanceof_static(zval *zv);
 ZEND_API void ZEND_FASTCALL zend_ref_add_type_source(zend_property_info_source_list *source_list, zend_property_info *prop);
 ZEND_API void ZEND_FASTCALL zend_ref_del_type_source(zend_property_info_source_list *source_list, zend_property_info *prop);
 
-ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, zend_uchar value_type, zend_bool strict, zend_refcounted *ref);
+ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, zend_uchar value_type, zend_bool strict);
 
-static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type, zend_refcounted *ref)
+static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
 {
+       zend_refcounted *ref = NULL;
+
+       if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
+               ref = Z_COUNTED_P(value);
+               value = Z_REFVAL_P(value);
+       }
+
        ZVAL_COPY_VALUE(variable_ptr, value);
        if (ZEND_CONST_COND(value_type  == IS_CONST, 0)) {
                if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
@@ -110,20 +117,13 @@ static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *v
 
 static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type, zend_bool strict)
 {
-       zend_refcounted *ref = NULL;
-
-       if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
-               ref = Z_COUNTED_P(value);
-               value = Z_REFVAL_P(value);
-       }
-
        do {
                if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
                        zend_refcounted *garbage;
 
                        if (Z_ISREF_P(variable_ptr)) {
                                if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) {
-                                       return zend_assign_to_typed_ref(variable_ptr, value, value_type, strict, ref);
+                                       return zend_assign_to_typed_ref(variable_ptr, value, value_type, strict);
                                }
 
                                variable_ptr = Z_REFVAL_P(variable_ptr);
@@ -132,7 +132,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
                                }
                        }
                        garbage = Z_COUNTED_P(variable_ptr);
-                       zend_copy_to_variable(variable_ptr, value, value_type, ref);
+                       zend_copy_to_variable(variable_ptr, value, value_type);
                        if (GC_DELREF(garbage) == 0) {
                                rc_dtor_func(garbage);
                        } else { /* we need to split */
@@ -145,7 +145,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
                }
        } while (0);
 
-       zend_copy_to_variable(variable_ptr, value, value_type, ref);
+       zend_copy_to_variable(variable_ptr, value, value_type);
        return variable_ptr;
 }