Skip to content

Commit 25aa84d

Browse files
committed
Remove unneessary variable and clean up goto boundary error
1 parent 28b6a00 commit 25aa84d

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
@@ -2725,7 +2725,7 @@ static uint8_t php_range_process_input(const zval *input, uint32_t arg_num, zend
27252725
PHP_FUNCTION(range)
27262726
{
27272727
zval *user_start, *user_end, *user_step = NULL, tmp;
2728-
bool err = 0, is_step_double = false;
2728+
bool is_step_double = false;
27292729
double step_double = 1.0;
27302730
zend_long step = 1;
27312731

@@ -2830,8 +2830,7 @@ PHP_FUNCTION(range)
28302830

28312831
if (low > high) { /* Negative Steps */
28322832
if (low - high < step) {
2833-
err = 1;
2834-
goto err;
2833+
goto boundary_error;
28352834
}
28362835
/* Initialize the return_value as an array. */
28372836
array_init_size(return_value, (uint32_t)(((low - high) / step) + 1));
@@ -2847,8 +2846,7 @@ PHP_FUNCTION(range)
28472846
} ZEND_HASH_FILL_END();
28482847
} else if (high > low) { /* Positive Steps */
28492848
if (high - low < step) {
2850-
err = 1;
2851-
goto err;
2849+
goto boundary_error;
28522850
}
28532851
array_init_size(return_value, (uint32_t)(((high - low) / step) + 1));
28542852
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
@@ -2876,8 +2874,7 @@ PHP_FUNCTION(range)
28762874

28772875
if (start_double > end_double) { /* Negative steps */
28782876
if (start_double - end_double < step_double) {
2879-
err = 1;
2880-
goto err;
2877+
goto boundary_error;
28812878
}
28822879

28832880
RANGE_CHECK_DOUBLE_INIT_ARRAY(start_double, end_double, step_double);
@@ -2890,8 +2887,7 @@ PHP_FUNCTION(range)
28902887
} ZEND_HASH_FILL_END();
28912888
} else if (end_double > start_double) { /* Positive steps */
28922889
if (end_double - start_double < step_double) {
2893-
err = 1;
2894-
goto err;
2890+
goto boundary_error;
28952891
}
28962892

28972893
RANGE_CHECK_DOUBLE_INIT_ARRAY(end_double, start_double, step_double);
@@ -2915,8 +2911,7 @@ PHP_FUNCTION(range)
29152911

29162912
if (start_long > end_long) { /* Negative steps */
29172913
if ((zend_ulong)start_long - end_long < unsigned_step) {
2918-
err = 1;
2919-
goto err;
2914+
goto boundary_error;
29202915
}
29212916

29222917
RANGE_CHECK_LONG_INIT_ARRAY(start_long, end_long, unsigned_step);
@@ -2929,8 +2924,7 @@ PHP_FUNCTION(range)
29292924
} ZEND_HASH_FILL_END();
29302925
} else if (end_long > start_long) { /* Positive steps */
29312926
if ((zend_ulong)end_long - start_long < unsigned_step) {
2932-
err = 1;
2933-
goto err;
2927+
goto boundary_error;
29342928
}
29352929

29362930
RANGE_CHECK_LONG_INIT_ARRAY(end_long, start_long, unsigned_step);
@@ -2947,11 +2941,11 @@ PHP_FUNCTION(range)
29472941
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
29482942
}
29492943
}
2950-
err:
2951-
if (err) {
2952-
zend_argument_value_error(3, "must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
2953-
RETURN_THROWS();
2954-
}
2944+
return;
2945+
2946+
boundary_error:
2947+
zend_argument_value_error(3, "must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
2948+
RETURN_THROWS();
29552949
}
29562950
/* }}} */
29572951

0 commit comments

Comments
 (0)