]> granicus.if.org Git - php/commitdiff
Removed useless IS_UNDEF checks
authorDmitry Stogov <dmitry@zend.com>
Tue, 31 Jul 2018 09:23:46 +0000 (12:23 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 31 Jul 2018 09:23:46 +0000 (12:23 +0300)
Zend/zend_interfaces.c
Zend/zend_object_handlers.c
ext/spl/spl_array.c
ext/spl/spl_directory.c
ext/spl/spl_fixedarray.c
ext/spl/spl_iterators.c
ext/standard/array.c
main/streams/userspace.c

index 728dd31348c303d9e7f00e206e0c2b226832d228..addc9e560f826749c3dd21ff8162d78e091227f2 100644 (file)
@@ -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;
 }
index 95ab3dc50c4ee1746c2333655f4a3f9ee158510f..1bb8ee81973104ba44a4b9a2cea55bb1c770f1c4 100644 (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(&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;
index 4eab55b7bfe3471632442bb48d37e58ef353de4e..63345e6e331d8eb880f0579a478f6c71caac7dd2 100644 (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);
                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;
index 0554226ad8e1c03057408ce5f855d947596e2f89..776f2ae44da24a2038030f5a3e3f93be1f61b766 100644 (file)
@@ -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;
index 3abd143636301ee41a5130cec218d6c39f9e9453..392175f781fc71e6bae069dbb63f78a20dc9c02d 100644 (file)
@@ -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);
index 3aca8b1dc5e02a17f30af89f1180e4dbd862128c..2ddb7b2a4fd31bd3e50c114e74e8a0163544b7b1 100644 (file)
@@ -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;
 }
 /* }}} */
index 6eb6947dcfd968079e009d6ce740bd4912fc80ea..ed917d71d064514534f8fca09ec0d4ea0b54ecc7 100644 (file)
@@ -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 {
index ab3ea073ddbbe811b90147458b4be2c1dcbc9f73..e69db525dadf13f3e544aa05ff745d4f0e3a0a2c 100644 (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!",
                                        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);