Skip to content

Commit 78c5d79

Browse files
committed
zend_builtin_functions.c: use RET{URN|VAL}_BOOL() when possible
1 parent 4e3c75b commit 78c5d79

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

Zend/zend_builtin_functions.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,7 @@ ZEND_FUNCTION(define)
588588
/* non persistent */
589589
ZEND_CONSTANT_SET_FLAGS(&c, 0, PHP_USER_CONSTANT);
590590
c.name = zend_string_copy(name);
591-
if (zend_register_constant(&c) != NULL) {
592-
RETURN_TRUE;
593-
} else {
594-
RETURN_FALSE;
595-
}
591+
RETURN_BOOL(zend_register_constant(&c) != NULL);
596592
}
597593
/* }}} */
598594

@@ -606,11 +602,7 @@ ZEND_FUNCTION(defined)
606602
Z_PARAM_STR(name)
607603
ZEND_PARSE_PARAMETERS_END();
608604

609-
if (zend_get_constant_ex(name, zend_get_executed_scope(), ZEND_FETCH_CLASS_SILENT)) {
610-
RETURN_TRUE;
611-
} else {
612-
RETURN_FALSE;
613-
}
605+
RETURN_BOOL(zend_get_constant_ex(name, zend_get_executed_scope(), ZEND_FETCH_CLASS_SILENT));
614606
}
615607
/* }}} */
616608

@@ -1043,11 +1035,10 @@ static void _property_exists(zval *return_value, const zval *object, zend_string
10431035
RETURN_TRUE;
10441036
}
10451037

1046-
if (Z_TYPE_P(object) == IS_OBJECT &&
1047-
Z_OBJ_HANDLER_P(object, has_property)(Z_OBJ_P(object), property, ZEND_PROPERTY_EXISTS, NULL)) {
1048-
RETURN_TRUE;
1049-
}
1050-
RETURN_FALSE;
1038+
RETURN_BOOL(
1039+
Z_TYPE_P(object) == IS_OBJECT &&
1040+
Z_OBJ_HANDLER_P(object, has_property)(Z_OBJ_P(object), property, ZEND_PROPERTY_EXISTS, NULL)
1041+
);
10511042
}
10521043

10531044
/* {{{ Checks if the object or class has a property */
@@ -1107,11 +1098,7 @@ static inline void _class_exists_impl(zval *return_value, zend_string *name, boo
11071098
ce = zend_lookup_class(name);
11081099
}
11091100

1110-
if (ce) {
1111-
RETURN_BOOL(((ce->ce_flags & flags) == flags) && !(ce->ce_flags & skip_flags));
1112-
} else {
1113-
RETURN_FALSE;
1114-
}
1101+
RETURN_BOOL(ce && ((ce->ce_flags & flags) == flags) && !(ce->ce_flags & skip_flags));
11151102
}
11161103
/* {{{ */
11171104

@@ -2223,11 +2210,7 @@ ZEND_FUNCTION(extension_loaded)
22232210
}
22242211

22252212
lcname = zend_string_tolower(extension_name);
2226-
if (zend_hash_exists(&module_registry, lcname)) {
2227-
RETVAL_TRUE;
2228-
} else {
2229-
RETVAL_FALSE;
2230-
}
2213+
RETVAL_BOOL(zend_hash_exists(&module_registry, lcname));
22312214
zend_string_release_ex(lcname, 0);
22322215
}
22332216
/* }}} */

0 commit comments

Comments
 (0)