Skip to content

Commit b92f92f

Browse files
committed
Remove unneessary variable and clean up goto boundary error
1 parent 7890ad2 commit b92f92f

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

ext/standard/array.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,7 @@ static uint8_t php_range_process_input(const zval *input, uint32_t arg_num, zend
28392839
PHP_FUNCTION(range)
28402840
{
28412841
zval *user_start, *user_end, *user_step = NULL, tmp;
2842-
bool err = 0, is_step_double = false;
2842+
bool is_step_double = false;
28432843
double step_double = 1.0;
28442844
zend_long step = 1;
28452845

@@ -2944,8 +2944,7 @@ PHP_FUNCTION(range)
29442944

29452945
if (low > high) { /* Negative Steps */
29462946
if (low - high < step) {
2947-
err = 1;
2948-
goto err;
2947+
goto boundary_error;
29492948
}
29502949
/* Initialize the return_value as an array. */
29512950
array_init_size(return_value, (uint32_t)(((low - high) / step) + 1));
@@ -2961,8 +2960,7 @@ PHP_FUNCTION(range)
29612960
} ZEND_HASH_FILL_END();
29622961
} else if (high > low) { /* Positive Steps */
29632962
if (high - low < step) {
2964-
err = 1;
2965-
goto err;
2963+
goto boundary_error;
29662964
}
29672965
array_init_size(return_value, (uint32_t)(((high - low) / step) + 1));
29682966
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
@@ -2990,8 +2988,7 @@ PHP_FUNCTION(range)
29902988

29912989
if (start_double > end_double) { /* Negative steps */
29922990
if (start_double - end_double < step_double) {
2993-
err = 1;
2994-
goto err;
2991+
goto boundary_error;
29952992
}
29962993

29972994
RANGE_CHECK_DOUBLE_INIT_ARRAY(start_double, end_double, step_double);
@@ -3004,8 +3001,7 @@ PHP_FUNCTION(range)
30043001
} ZEND_HASH_FILL_END();
30053002
} else if (end_double > start_double) { /* Positive steps */
30063003
if (end_double - start_double < step_double) {
3007-
err = 1;
3008-
goto err;
3004+
goto boundary_error;
30093005
}
30103006

30113007
RANGE_CHECK_DOUBLE_INIT_ARRAY(end_double, start_double, step_double);
@@ -3029,8 +3025,7 @@ PHP_FUNCTION(range)
30293025

30303026
if (start_long > end_long) { /* Negative steps */
30313027
if ((zend_ulong)start_long - end_long < unsigned_step) {
3032-
err = 1;
3033-
goto err;
3028+
goto boundary_error;
30343029
}
30353030

30363031
RANGE_CHECK_LONG_INIT_ARRAY(start_long, end_long, unsigned_step);
@@ -3043,8 +3038,7 @@ PHP_FUNCTION(range)
30433038
} ZEND_HASH_FILL_END();
30443039
} else if (end_long > start_long) { /* Positive steps */
30453040
if ((zend_ulong)end_long - start_long < unsigned_step) {
3046-
err = 1;
3047-
goto err;
3041+
goto boundary_error;
30483042
}
30493043

30503044
RANGE_CHECK_LONG_INIT_ARRAY(end_long, start_long, unsigned_step);
@@ -3061,11 +3055,11 @@ PHP_FUNCTION(range)
30613055
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
30623056
}
30633057
}
3064-
err:
3065-
if (err) {
3066-
zend_argument_value_error(3, "must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
3067-
RETURN_THROWS();
3068-
}
3058+
return;
3059+
3060+
boundary_error:
3061+
zend_argument_value_error(3, "must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
3062+
RETURN_THROWS();
30693063
}
30703064
/* }}} */
30713065

0 commit comments

Comments
 (0)