diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-07-31 12:23:46 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-07-31 12:23:46 +0300 |
commit | c42f0ba4f70f83b33eb21250f2ab2c782cfb9dea (patch) | |
tree | d055abd29feeab341ce47c7c2e1d1721d98666b3 | |
parent | 7c1e0930c4c2e433e01884253dd1539ca8c31bd3 (diff) | |
download | php-git-c42f0ba4f70f83b33eb21250f2ab2c782cfb9dea.tar.gz |
Removed useless IS_UNDEF checks
-rw-r--r-- | Zend/zend_interfaces.c | 8 | ||||
-rw-r--r-- | Zend/zend_object_handlers.c | 42 | ||||
-rw-r--r-- | ext/spl/spl_array.c | 2 | ||||
-rw-r--r-- | ext/spl/spl_directory.c | 6 | ||||
-rw-r--r-- | ext/spl/spl_fixedarray.c | 11 | ||||
-rw-r--r-- | ext/spl/spl_iterators.c | 8 | ||||
-rw-r--r-- | ext/standard/array.c | 13 | ||||
-rw-r--r-- | main/streams/userspace.c | 4 |
8 files changed, 35 insertions, 59 deletions
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 728dd31348..addc9e560f 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -161,11 +161,9 @@ 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; - } + result = i_zend_is_true(&more); + zval_ptr_dtor(&more); + return result ? SUCCESS : FAILURE; } return FAILURE; } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 95ab3dc50c..1bb8ee8197 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -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(&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); 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); @@ -1690,23 +1684,17 @@ 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) { - if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) { - (*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; - } + result = zend_is_true(&rv); + zval_ptr_dtor(&rv); + if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY && result) { + if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) { + (*guard) |= IN_GET; + zend_std_call_getter(zobj, member, &rv); + (*guard) &= ~IN_GET; + result = i_zend_is_true(&rv); + zval_ptr_dtor(&rv); + } else { + result = 0; } } (*guard) &= ~IN_ISSET; diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 4eab55b7bf..63345e6e33 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -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; diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 0554226ad8..776f2ae44d 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -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); - } + 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; diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 3abd143636..392175f781 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -507,15 +507,14 @@ 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); - zval_ptr_dtor(&rv); - return result; - } - return 0; + result = zend_is_true(&rv); + zval_ptr_dtor(&rv); + return result; } return spl_fixedarray_object_has_dimension_helper(intern, offset, check_empty); diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 3aca8b1dc5..2ddb7b2a4f 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -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; - } + result = zend_is_true(&retval) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_STOP; + zval_ptr_dtor(&retval); return result; } /* }}} */ diff --git a/ext/standard/array.c b/ext/standard/array.c index 6eb6947dcf..ed917d71d0 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -6056,18 +6056,15 @@ 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); - - zval_ptr_dtor(&retval); - if (!retval_true) { - continue; - } - } else { + retval_true = zend_is_true(&retval); + zval_ptr_dtor(&retval); + if (!retval_true) { continue; } } else { diff --git a/main/streams/userspace.c b/main/streams/userspace.c index ab3ea073dd..e69db525da 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -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); |