Removed useless IS_UNDEF checks

This commit is contained in:
Dmitry Stogov 2018-07-31 12:23:46 +03:00
parent 7c1e0930c4
commit c42f0ba4f7
8 changed files with 35 additions and 59 deletions

View file

@ -161,11 +161,9 @@ ZEND_API int zend_user_it_valid(zend_object_iterator *_iter)
int result; int result;
zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs_ptr->zf_valid, "valid", &more); zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs_ptr->zf_valid, "valid", &more);
if (Z_TYPE(more) != IS_UNDEF) { result = i_zend_is_true(&more);
result = i_zend_is_true(&more); zval_ptr_dtor(&more);
zval_ptr_dtor(&more); return result ? SUCCESS : FAILURE;
return result ? SUCCESS : FAILURE;
}
} }
return FAILURE; return FAILURE;
} }

View file

@ -909,18 +909,12 @@ ZEND_API int zend_std_has_dimension(zval *object, zval *offset, int check_empty)
ZVAL_COPY_DEREF(&tmp_offset, offset); ZVAL_COPY_DEREF(&tmp_offset, offset);
ZVAL_COPY(&tmp_object, object); ZVAL_COPY(&tmp_object, object);
zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetexists", &retval, &tmp_offset); zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetexists", &retval, &tmp_offset);
if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) { result = i_zend_is_true(&retval);
zval_ptr_dtor(&retval);
if (check_empty && result && EXPECTED(!EG(exception))) {
zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetget", &retval, &tmp_offset);
result = i_zend_is_true(&retval); result = i_zend_is_true(&retval);
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
if (check_empty && result && EXPECTED(!EG(exception))) {
zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetget", &retval, &tmp_offset);
if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) {
result = i_zend_is_true(&retval);
zval_ptr_dtor(&retval);
}
}
} else {
result = 0;
} }
zval_ptr_dtor(&tmp_object); zval_ptr_dtor(&tmp_object);
zval_ptr_dtor(&tmp_offset); zval_ptr_dtor(&tmp_offset);
@ -1690,23 +1684,17 @@ found:
GC_ADDREF(zobj); GC_ADDREF(zobj);
(*guard) |= IN_ISSET; /* prevent circular getting */ (*guard) |= IN_ISSET; /* prevent circular getting */
zend_std_call_issetter(zobj, member, &rv); zend_std_call_issetter(zobj, member, &rv);
if (Z_TYPE(rv) != IS_UNDEF) { result = zend_is_true(&rv);
result = zend_is_true(&rv); zval_ptr_dtor(&rv);
zval_ptr_dtor(&rv); if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY && result) {
if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY && result) { if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) {
if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) { (*guard) |= IN_GET;
(*guard) |= IN_GET; zend_std_call_getter(zobj, member, &rv);
zend_std_call_getter(zobj, member, &rv); (*guard) &= ~IN_GET;
(*guard) &= ~IN_GET; result = i_zend_is_true(&rv);
if (Z_TYPE(rv) != IS_UNDEF) { zval_ptr_dtor(&rv);
result = i_zend_is_true(&rv); } else {
zval_ptr_dtor(&rv); result = 0;
} else {
result = 0;
}
} else {
result = 0;
}
} }
} }
(*guard) &= ~IN_ISSET; (*guard) &= ~IN_ISSET;

View file

@ -617,7 +617,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
zend_call_method_with_1_params(object, Z_OBJCE_P(object), &intern->fptr_offset_has, "offsetExists", &rv, offset); zend_call_method_with_1_params(object, Z_OBJCE_P(object), &intern->fptr_offset_has, "offsetExists", &rv, offset);
zval_ptr_dtor(offset); zval_ptr_dtor(offset);
if (!Z_ISUNDEF(rv) && zend_is_true(&rv)) { if (zend_is_true(&rv)) {
zval_ptr_dtor(&rv); zval_ptr_dtor(&rv);
if (check_empty != 1) { if (check_empty != 1) {
return 1; return 1;

View file

@ -846,10 +846,8 @@ SPL_METHOD(DirectoryIterator, seek)
while (intern->u.dir.index < pos) { while (intern->u.dir.index < pos) {
int valid = 0; int valid = 0;
zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_valid, "valid", &retval); zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_valid, "valid", &retval);
if (!Z_ISUNDEF(retval)) { valid = zend_is_true(&retval);
valid = zend_is_true(&retval); zval_ptr_dtor(&retval);
zval_ptr_dtor(&retval);
}
if (!valid) { if (!valid) {
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", pos); zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", pos);
return; return;

View file

@ -507,15 +507,14 @@ static int spl_fixedarray_object_has_dimension(zval *object, zval *offset, int c
if (intern->fptr_offset_has) { if (intern->fptr_offset_has) {
zval rv; zval rv;
zend_bool result;
SEPARATE_ARG_IF_REF(offset); SEPARATE_ARG_IF_REF(offset);
zend_call_method_with_1_params(object, intern->std.ce, &intern->fptr_offset_has, "offsetExists", &rv, offset); zend_call_method_with_1_params(object, intern->std.ce, &intern->fptr_offset_has, "offsetExists", &rv, offset);
zval_ptr_dtor(offset); zval_ptr_dtor(offset);
if (!Z_ISUNDEF(rv)) { result = zend_is_true(&rv);
zend_bool result = zend_is_true(&rv); zval_ptr_dtor(&rv);
zval_ptr_dtor(&rv); return result;
return result;
}
return 0;
} }
return spl_fixedarray_object_has_dimension_helper(intern, offset, check_empty); return spl_fixedarray_object_has_dimension_helper(intern, offset, check_empty);

View file

@ -3644,12 +3644,8 @@ static int spl_iterator_func_apply(zend_object_iterator *iter, void *puser) /* {
apply_info->count++; apply_info->count++;
zend_fcall_info_call(&apply_info->fci, &apply_info->fcc, &retval, NULL); zend_fcall_info_call(&apply_info->fci, &apply_info->fcc, &retval, NULL);
if (Z_TYPE(retval) != IS_UNDEF) { result = zend_is_true(&retval) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_STOP;
result = zend_is_true(&retval) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_STOP; zval_ptr_dtor(&retval);
zval_ptr_dtor(&retval);
} else {
result = ZEND_HASH_APPLY_STOP;
}
return result; return result;
} }
/* }}} */ /* }}} */

View file

@ -6056,18 +6056,15 @@ PHP_FUNCTION(array_filter)
fci.params = args; fci.params = args;
if (zend_call_function(&fci, &fci_cache) == SUCCESS) { if (zend_call_function(&fci, &fci_cache) == SUCCESS) {
int retval_true;
zval_ptr_dtor(&args[0]); zval_ptr_dtor(&args[0]);
if (use_type == ARRAY_FILTER_USE_BOTH) { if (use_type == ARRAY_FILTER_USE_BOTH) {
zval_ptr_dtor(&args[1]); zval_ptr_dtor(&args[1]);
} }
if (!Z_ISUNDEF(retval)) { retval_true = zend_is_true(&retval);
int retval_true = zend_is_true(&retval); zval_ptr_dtor(&retval);
if (!retval_true) {
zval_ptr_dtor(&retval);
if (!retval_true) {
continue;
}
} else {
continue; continue;
} }
} else { } else {

View file

@ -1067,7 +1067,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_SET_OPTION " is not implemented!", php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_SET_OPTION " is not implemented!",
us->wrapper->classname); us->wrapper->classname);
ret = PHP_STREAM_OPTION_RETURN_ERR; ret = PHP_STREAM_OPTION_RETURN_ERR;
} else if (Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval)) { } else if (zend_is_true(&retval)) {
ret = PHP_STREAM_OPTION_RETURN_OK; ret = PHP_STREAM_OPTION_RETURN_OK;
} else { } else {
ret = PHP_STREAM_OPTION_RETURN_ERR; ret = PHP_STREAM_OPTION_RETURN_ERR;
@ -1512,7 +1512,7 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
us->wrapper->classname); us->wrapper->classname);
break; break;
} }
if (Z_ISUNDEF(retval) || !zend_is_true(&retval)) { if (!zend_is_true(&retval)) {
break; break;
} }
php_stream_from_zval_no_verify(intstream, &retval); php_stream_from_zval_no_verify(intstream, &retval);