Skip to content

Commit 1893668

Browse files
committed
more
1 parent ffdf089 commit 1893668

File tree

1 file changed

+25
-32
lines changed

1 file changed

+25
-32
lines changed

Zend/zend_API.c

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -555,15 +555,12 @@ ZEND_API zend_opt_bool ZEND_FASTCALL zend_flf_parse_arg_bool_slow(const zval *ar
555555

556556
ZEND_API zend_opt_long ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, uint32_t arg_num) /* {{{ */
557557
{
558-
zend_opt_long result;
559-
result.has_value = false;
560-
561558
if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
562559
if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
563-
return result;
560+
goto fail;
564561
}
565562
if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg)))) {
566-
return result;
563+
goto fail;
567564
} else {
568565
zend_long lval = zend_dval_to_lval(Z_DVAL_P(arg));
569566
if (UNEXPECTED(!zend_is_long_compatible(Z_DVAL_P(arg), lval))) {
@@ -573,23 +570,23 @@ ZEND_API zend_opt_long ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, u
573570
zend_incompatible_double_to_long_error(Z_DVAL_P(arg));
574571
}
575572
if (UNEXPECTED(EG(exception))) {
576-
return result;
573+
goto fail;
577574
}
578575
}
579-
result.value = lval;
576+
return (zend_opt_long){lval, true};
580577
}
581578
} else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
582579
double d;
583580
uint8_t type;
581+
zend_long lval;
584582

585-
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &result.value, &d)) != IS_LONG)) {
583+
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &lval, &d)) != IS_LONG)) {
586584
if (EXPECTED(type != 0)) {
587-
zend_long lval;
588585
if (UNEXPECTED(zend_isnan(d))) {
589-
return result;
586+
goto fail;
590587
}
591588
if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(d))) {
592-
return result;
589+
goto fail;
593590
}
594591

595592
lval = zend_dval_to_lval(d);
@@ -601,28 +598,27 @@ ZEND_API zend_opt_long ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, u
601598
zend_incompatible_string_to_long_error(Z_STR_P(arg));
602599
}
603600
if (UNEXPECTED(EG(exception))) {
604-
return result;
601+
goto fail;
605602
}
606603
}
607-
result.value = lval;
608-
} else {
609-
return result;
610604
}
605+
return (zend_opt_long){lval, true};
611606
}
612607
if (UNEXPECTED(EG(exception))) {
613-
return result;
608+
goto fail;
614609
}
615610
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
616611
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int", arg_num)) {
617-
return result;
612+
goto fail;
618613
}
619-
result.value = 0;
614+
return (zend_opt_long){0, true};
620615
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
621-
result.value = 1;
622-
} else {
623-
return result;
616+
return (zend_opt_long){1, true};
624617
}
625-
result.has_value = true;
618+
619+
fail:;
620+
zend_opt_long result;
621+
result.has_value = false;
626622
return result;
627623
}
628624
/* }}} */
@@ -670,24 +666,21 @@ ZEND_API zend_opt_double ZEND_FASTCALL zend_parse_arg_double_weak(const zval *ar
670666
return (zend_opt_double){d, true};
671667
}
672668
if (UNEXPECTED(EG(exception))) {
673-
zend_opt_double result;
674-
result.has_value = false;
675-
return result;
669+
goto fail;
676670
}
677671
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
678672
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("float", arg_num)) {
679-
zend_opt_double result;
680-
result.has_value = false;
681-
return result;
673+
goto fail;
682674
}
683675
return (zend_opt_double){0.0, true};
684676
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
685677
return (zend_opt_double){1.0, true};
686-
} else {
687-
zend_opt_double result;
688-
result.has_value = false;
689-
return result;
690678
}
679+
680+
fail:;
681+
zend_opt_double result;
682+
result.has_value = false;
683+
return result;
691684
}
692685
/* }}} */
693686

0 commit comments

Comments
 (0)