Skip to content

Commit 4f51aad

Browse files
committed
Remove unneessary variable and clean up goto boundary error
1 parent b4aaa51 commit 4f51aad

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
@@ -2753,7 +2753,7 @@ static uint8_t php_range_process_input(const zval *input, uint32_t arg_num, zend
27532753
PHP_FUNCTION(range)
27542754
{
27552755
zval *user_start, *user_end, *user_step = NULL, tmp;
2756-
bool err = 0, is_step_double = false;
2756+
bool is_step_double = false;
27572757
double step_double = 1.0;
27582758
zend_long step = 1;
27592759

@@ -2858,8 +2858,7 @@ PHP_FUNCTION(range)
28582858

28592859
if (low > high) { /* Negative Steps */
28602860
if (low - high < step) {
2861-
err = 1;
2862-
goto err;
2861+
goto boundary_error;
28632862
}
28642863
/* Initialize the return_value as an array. */
28652864
array_init_size(return_value, (uint32_t)(((low - high) / step) + 1));
@@ -2875,8 +2874,7 @@ PHP_FUNCTION(range)
28752874
} ZEND_HASH_FILL_END();
28762875
} else if (high > low) { /* Positive Steps */
28772876
if (high - low < step) {
2878-
err = 1;
2879-
goto err;
2877+
goto boundary_error;
28802878
}
28812879
array_init_size(return_value, (uint32_t)(((high - low) / step) + 1));
28822880
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
@@ -2904,8 +2902,7 @@ PHP_FUNCTION(range)
29042902

29052903
if (start_double > end_double) { /* Negative steps */
29062904
if (start_double - end_double < step_double) {
2907-
err = 1;
2908-
goto err;
2905+
goto boundary_error;
29092906
}
29102907

29112908
RANGE_CHECK_DOUBLE_INIT_ARRAY(start_double, end_double, step_double);
@@ -2918,8 +2915,7 @@ PHP_FUNCTION(range)
29182915
} ZEND_HASH_FILL_END();
29192916
} else if (end_double > start_double) { /* Positive steps */
29202917
if (end_double - start_double < step_double) {
2921-
err = 1;
2922-
goto err;
2918+
goto boundary_error;
29232919
}
29242920

29252921
RANGE_CHECK_DOUBLE_INIT_ARRAY(end_double, start_double, step_double);
@@ -2943,8 +2939,7 @@ PHP_FUNCTION(range)
29432939

29442940
if (start_long > end_long) { /* Negative steps */
29452941
if ((zend_ulong)start_long - end_long < unsigned_step) {
2946-
err = 1;
2947-
goto err;
2942+
goto boundary_error;
29482943
}
29492944

29502945
RANGE_CHECK_LONG_INIT_ARRAY(start_long, end_long, unsigned_step);
@@ -2957,8 +2952,7 @@ PHP_FUNCTION(range)
29572952
} ZEND_HASH_FILL_END();
29582953
} else if (end_long > start_long) { /* Positive steps */
29592954
if ((zend_ulong)end_long - start_long < unsigned_step) {
2960-
err = 1;
2961-
goto err;
2955+
goto boundary_error;
29622956
}
29632957

29642958
RANGE_CHECK_LONG_INIT_ARRAY(end_long, start_long, unsigned_step);
@@ -2975,11 +2969,11 @@ PHP_FUNCTION(range)
29752969
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
29762970
}
29772971
}
2978-
err:
2979-
if (err) {
2980-
zend_argument_value_error(3, "must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
2981-
RETURN_THROWS();
2982-
}
2972+
return;
2973+
2974+
boundary_error:
2975+
zend_argument_value_error(3, "must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
2976+
RETURN_THROWS();
29832977
}
29842978
/* }}} */
29852979

0 commit comments

Comments
 (0)