]> granicus.if.org Git - php/commitdiff
Remove some unnecessary duplications
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 30 Oct 2017 21:48:20 +0000 (22:48 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 30 Oct 2017 21:48:20 +0000 (22:48 +0100)
Zend/zend_builtin_functions.c
Zend/zend_generators.c
ext/reflection/php_reflection.c

index 37bf4f82e0d297da78a8e984c468b03925ee3a5f..04bb9142d272865131bd7b0aff010fb22cfb28ee 100644 (file)
@@ -647,14 +647,9 @@ ZEND_FUNCTION(each)
        zend_hash_real_init(Z_ARRVAL_P(return_value), 0);
 
        /* add value elements */
-       if (Z_ISREF_P(entry)) {
-               ZVAL_DUP(&tmp, Z_REFVAL_P(entry));
-               entry = &tmp;
-               if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
-       } else {
-               if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
-               if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
-       }
+       ZVAL_DEREF(entry);
+       if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
+       if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
        zend_hash_index_add_new(Z_ARRVAL_P(return_value), 1, entry);
        zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_VALUE), entry);
 
index 43dfc00e10efdd98ce898534566715b9dff22df6..e47be9685027df3a22f09ce29423ba8651d63131 100644 (file)
@@ -1014,14 +1014,14 @@ ZEND_METHOD(Generator, send)
  * Throws an exception into the generator */
 ZEND_METHOD(Generator, throw)
 {
-       zval *exception, exception_copy;
+       zval *exception;
        zend_generator *generator;
 
        ZEND_PARSE_PARAMETERS_START(1, 1)
                Z_PARAM_ZVAL(exception)
        ZEND_PARSE_PARAMETERS_END();
 
-       ZVAL_DUP(&exception_copy, exception);
+       Z_TRY_ADDREF_P(exception);
 
        generator = (zend_generator *) Z_OBJ_P(getThis());
 
@@ -1030,7 +1030,7 @@ ZEND_METHOD(Generator, throw)
        if (generator->execute_data) {
                zend_generator *root = zend_generator_get_current(generator);
 
-               zend_generator_throw_exception(root, &exception_copy);
+               zend_generator_throw_exception(root, exception);
 
                zend_generator_resume(generator);
 
@@ -1044,7 +1044,7 @@ ZEND_METHOD(Generator, throw)
        } else {
                /* If the generator is already closed throw the exception in the
                 * current context */
-               zend_throw_exception_object(&exception_copy);
+               zend_throw_exception_object(exception);
        }
 }
 /* }}} */
index 36af4a193a845f8f8d77d406289560e48fa87877..300d17326e7ee44699d8ef56f833304c3623a8d6 100644 (file)
@@ -175,24 +175,10 @@ static void _default_get_entry(zval *object, char *name, int name_len, zval *ret
        if ((value = _default_load_entry(object, name, name_len)) == NULL) {
                RETURN_FALSE;
        }
-       ZVAL_DUP(return_value, value);
+       ZVAL_COPY(return_value, value);
 }
 /* }}} */
 
-#ifdef ilia_0
-static void _default_lookup_entry(zval *object, char *name, int name_len, zval **return_value) /* {{{ */
-{
-       zval **value;
-
-       if (zend_hash_find(Z_OBJPROP_P(object), name, name_len, (void **) &value) == FAILURE) {
-               *return_value = NULL;
-       } else {
-               *return_value = *value;
-       }
-}
-/* }}} */
-#endif
-
 static zend_function *_copy_function(zend_function *fptr) /* {{{ */
 {
        if (fptr
@@ -649,7 +635,7 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_
                        zval zv;
 
                        smart_str_appends(str, " = ");
-                       ZVAL_DUP(&zv, RT_CONSTANT(precv, precv->op2));
+                       ZVAL_COPY(&zv, RT_CONSTANT(precv, precv->op2));
                        if (UNEXPECTED(zval_update_constant_ex(&zv, fptr->common.scope) == FAILURE)) {
                                zval_ptr_dtor(&zv);
                                return;
@@ -2812,7 +2798,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
                return;
        }
 
-       ZVAL_DUP(return_value, RT_CONSTANT(precv, precv->op2));
+       ZVAL_COPY(return_value, RT_CONSTANT(precv, precv->op2));
        if (Z_TYPE_P(return_value) == IS_CONSTANT_AST) {
                zval_update_constant_ex(return_value, param->fptr->common.scope);
        }