]> granicus.if.org Git - php/commitdiff
Remove unnecessary result variable
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 20 Jan 2020 10:05:34 +0000 (11:05 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 20 Jan 2020 10:08:51 +0000 (11:08 +0100)
Instead directly use return_value. Hopefully this also works
around the "may be uninitialized" warning...

ext/standard/array.c

index 91e3c388d4524aa166c2c0d8c8b8c86a21f2b662..14ff138004748021f1dab52c8f9a984fc575ff3d 100644 (file)
@@ -6011,7 +6011,6 @@ PHP_FUNCTION(array_reduce)
        zval *input;
        zval args[2];
        zval *operand;
-       zval result;
        zval retval;
        zend_fcall_info fci;
        zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
@@ -6027,9 +6026,9 @@ PHP_FUNCTION(array_reduce)
 
 
        if (ZEND_NUM_ARGS() > 2) {
-               ZVAL_COPY(&result, initial);
+               ZVAL_COPY(return_value, initial);
        } else {
-               ZVAL_NULL(&result);
+               ZVAL_NULL(return_value);
        }
 
        /* (zval **)input points to an element of argument stack
@@ -6038,7 +6037,6 @@ PHP_FUNCTION(array_reduce)
        htbl = Z_ARRVAL_P(input);
 
        if (zend_hash_num_elements(htbl) == 0) {
-               ZVAL_COPY_VALUE(return_value, &result);
                zend_release_fcall_info_cache(&fci_cache);
                return;
        }
@@ -6048,14 +6046,14 @@ PHP_FUNCTION(array_reduce)
        fci.no_separation = 0;
 
        ZEND_HASH_FOREACH_VAL(htbl, operand) {
-               ZVAL_COPY_VALUE(&args[0], &result);
+               ZVAL_COPY_VALUE(&args[0], return_value);
                ZVAL_COPY(&args[1], operand);
                fci.params = args;
 
                if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
                        zval_ptr_dtor(&args[1]);
                        zval_ptr_dtor(&args[0]);
-                       ZVAL_COPY_VALUE(&result, &retval);
+                       ZVAL_COPY_VALUE(return_value, &retval);
                } else {
                        zval_ptr_dtor(&args[1]);
                        zval_ptr_dtor(&args[0]);
@@ -6064,7 +6062,6 @@ PHP_FUNCTION(array_reduce)
        } ZEND_HASH_FOREACH_END();
 
        zend_release_fcall_info_cache(&fci_cache);
-       RETURN_COPY_VALUE(&result);
 }
 /* }}} */