Skip to content

Commit 14f21a8

Browse files
committed
test struct in-place with return
1 parent 9806445 commit 14f21a8

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Zend/zend_API.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,36 +658,44 @@ ZEND_API zend_opt_long ZEND_FASTCALL zend_flf_parse_arg_long_slow(const zval *ar
658658

659659
ZEND_API zend_opt_double ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, uint32_t arg_num) /* {{{ */
660660
{
661-
zend_opt_double result;
662-
result.has_value = false;
663661
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
664-
result.value = (double)Z_LVAL_P(arg);
662+
return (zend_opt_double){(double)Z_LVAL_P(arg), true};
665663
} else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
666664
zend_long l;
667665
uint8_t type;
666+
double d;
668667

669-
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, &result.value)) != IS_DOUBLE)) {
668+
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, &d)) != IS_DOUBLE)) {
669+
zend_opt_double result;
670670
if (EXPECTED(type != 0)) {
671671
result.value = (double)(l);
672672
result.has_value = true;
673+
} else {
674+
result.has_value = false;
673675
}
674676
return result;
677+
} else {
678+
return (zend_opt_double){d, true};
675679
}
676680
if (UNEXPECTED(EG(exception))) {
681+
zend_opt_double result;
682+
result.has_value = false;
677683
return result;
678684
}
679685
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
680686
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("float", arg_num)) {
687+
zend_opt_double result;
688+
result.has_value = false;
681689
return result;
682690
}
683-
result.value = 0.0;
691+
return (zend_opt_double){0.0, true};
684692
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
685-
result.value = 1.0;
693+
return (zend_opt_double){1.0, true};
686694
} else {
695+
zend_opt_double result;
696+
result.has_value = false;
687697
return result;
688698
}
689-
result.has_value = true;
690-
return result;
691699
}
692700
/* }}} */
693701

0 commit comments

Comments
 (0)