mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Removed useless IS_UNDEF checks
This commit is contained in:
parent
7c1e0930c4
commit
c42f0ba4f7
8 changed files with 35 additions and 59 deletions
|
@ -161,12 +161,10 @@ ZEND_API int zend_user_it_valid(zend_object_iterator *_iter)
|
|||
int result;
|
||||
|
||||
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);
|
||||
zval_ptr_dtor(&more);
|
||||
return result ? SUCCESS : FAILURE;
|
||||
}
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -909,19 +909,13 @@ ZEND_API int zend_std_has_dimension(zval *object, zval *offset, int check_empty)
|
|||
ZVAL_COPY_DEREF(&tmp_offset, offset);
|
||||
ZVAL_COPY(&tmp_object, object);
|
||||
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);
|
||||
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_offset);
|
||||
} else {
|
||||
|
@ -1690,7 +1684,6 @@ found:
|
|||
GC_ADDREF(zobj);
|
||||
(*guard) |= IN_ISSET; /* prevent circular getting */
|
||||
zend_std_call_issetter(zobj, member, &rv);
|
||||
if (Z_TYPE(rv) != IS_UNDEF) {
|
||||
result = zend_is_true(&rv);
|
||||
zval_ptr_dtor(&rv);
|
||||
if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY && result) {
|
||||
|
@ -1698,16 +1691,11 @@ found:
|
|||
(*guard) |= IN_GET;
|
||||
zend_std_call_getter(zobj, member, &rv);
|
||||
(*guard) &= ~IN_GET;
|
||||
if (Z_TYPE(rv) != IS_UNDEF) {
|
||||
result = i_zend_is_true(&rv);
|
||||
zval_ptr_dtor(&rv);
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
(*guard) &= ~IN_ISSET;
|
||||
OBJ_RELEASE(zobj);
|
||||
|
|
|
@ -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);
|
||||
zval_ptr_dtor(offset);
|
||||
|
||||
if (!Z_ISUNDEF(rv) && zend_is_true(&rv)) {
|
||||
if (zend_is_true(&rv)) {
|
||||
zval_ptr_dtor(&rv);
|
||||
if (check_empty != 1) {
|
||||
return 1;
|
||||
|
|
|
@ -846,10 +846,8 @@ SPL_METHOD(DirectoryIterator, seek)
|
|||
while (intern->u.dir.index < pos) {
|
||||
int valid = 0;
|
||||
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);
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
if (!valid) {
|
||||
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", pos);
|
||||
return;
|
||||
|
|
|
@ -507,16 +507,15 @@ static int spl_fixedarray_object_has_dimension(zval *object, zval *offset, int c
|
|||
|
||||
if (intern->fptr_offset_has) {
|
||||
zval rv;
|
||||
zend_bool result;
|
||||
|
||||
SEPARATE_ARG_IF_REF(offset);
|
||||
zend_call_method_with_1_params(object, intern->std.ce, &intern->fptr_offset_has, "offsetExists", &rv, offset);
|
||||
zval_ptr_dtor(offset);
|
||||
if (!Z_ISUNDEF(rv)) {
|
||||
zend_bool result = zend_is_true(&rv);
|
||||
result = zend_is_true(&rv);
|
||||
zval_ptr_dtor(&rv);
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return spl_fixedarray_object_has_dimension_helper(intern, offset, check_empty);
|
||||
}
|
||||
|
|
|
@ -3644,12 +3644,8 @@ static int spl_iterator_func_apply(zend_object_iterator *iter, void *puser) /* {
|
|||
|
||||
apply_info->count++;
|
||||
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;
|
||||
zval_ptr_dtor(&retval);
|
||||
} else {
|
||||
result = ZEND_HASH_APPLY_STOP;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -6056,20 +6056,17 @@ PHP_FUNCTION(array_filter)
|
|||
fci.params = args;
|
||||
|
||||
if (zend_call_function(&fci, &fci_cache) == SUCCESS) {
|
||||
int retval_true;
|
||||
|
||||
zval_ptr_dtor(&args[0]);
|
||||
if (use_type == ARRAY_FILTER_USE_BOTH) {
|
||||
zval_ptr_dtor(&args[1]);
|
||||
}
|
||||
if (!Z_ISUNDEF(retval)) {
|
||||
int retval_true = zend_is_true(&retval);
|
||||
|
||||
retval_true = zend_is_true(&retval);
|
||||
zval_ptr_dtor(&retval);
|
||||
if (!retval_true) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
zval_ptr_dtor(&args[0]);
|
||||
if (use_type == ARRAY_FILTER_USE_BOTH) {
|
||||
|
|
|
@ -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!",
|
||||
us->wrapper->classname);
|
||||
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;
|
||||
} else {
|
||||
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);
|
||||
break;
|
||||
}
|
||||
if (Z_ISUNDEF(retval) || !zend_is_true(&retval)) {
|
||||
if (!zend_is_true(&retval)) {
|
||||
break;
|
||||
}
|
||||
php_stream_from_zval_no_verify(intstream, &retval);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue