Skip to content

Commit 0fbdc5a

Browse files
committed
Remove unnecessary result variable
Instead directly use return_value. Hopefully this also works around the "may be uninitialized" warning...
1 parent 6811222 commit 0fbdc5a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

ext/standard/array.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6011,7 +6011,6 @@ PHP_FUNCTION(array_reduce)
60116011
zval *input;
60126012
zval args[2];
60136013
zval *operand;
6014-
zval result;
60156014
zval retval;
60166015
zend_fcall_info fci;
60176016
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
@@ -6027,9 +6026,9 @@ PHP_FUNCTION(array_reduce)
60276026

60286027

60296028
if (ZEND_NUM_ARGS() > 2) {
6030-
ZVAL_COPY(&result, initial);
6029+
ZVAL_COPY(return_value, initial);
60316030
} else {
6032-
ZVAL_NULL(&result);
6031+
ZVAL_NULL(return_value);
60336032
}
60346033

60356034
/* (zval **)input points to an element of argument stack
@@ -6038,7 +6037,6 @@ PHP_FUNCTION(array_reduce)
60386037
htbl = Z_ARRVAL_P(input);
60396038

60406039
if (zend_hash_num_elements(htbl) == 0) {
6041-
ZVAL_COPY_VALUE(return_value, &result);
60426040
zend_release_fcall_info_cache(&fci_cache);
60436041
return;
60446042
}
@@ -6048,14 +6046,14 @@ PHP_FUNCTION(array_reduce)
60486046
fci.no_separation = 0;
60496047

60506048
ZEND_HASH_FOREACH_VAL(htbl, operand) {
6051-
ZVAL_COPY_VALUE(&args[0], &result);
6049+
ZVAL_COPY_VALUE(&args[0], return_value);
60526050
ZVAL_COPY(&args[1], operand);
60536051
fci.params = args;
60546052

60556053
if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
60566054
zval_ptr_dtor(&args[1]);
60576055
zval_ptr_dtor(&args[0]);
6058-
ZVAL_COPY_VALUE(&result, &retval);
6056+
ZVAL_COPY_VALUE(return_value, &retval);
60596057
} else {
60606058
zval_ptr_dtor(&args[1]);
60616059
zval_ptr_dtor(&args[0]);
@@ -6064,7 +6062,6 @@ PHP_FUNCTION(array_reduce)
60646062
} ZEND_HASH_FOREACH_END();
60656063

60666064
zend_release_fcall_info_cache(&fci_cache);
6067-
RETURN_COPY_VALUE(&result);
60686065
}
60696066
/* }}} */
60706067

0 commit comments

Comments
 (0)