diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-24 17:40:25 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-24 17:40:25 +0200 |
commit | 435f2691088fa9011696fd331d401544155d69a9 (patch) | |
tree | 43c71f7742584b75e895dace964171fa9e953f0d /Zend/zend_operators.c | |
parent | 93a9b56c90c334896e977721bfb3f38b1721cec6 (diff) | |
download | php-git-435f2691088fa9011696fd331d401544155d69a9.tar.gz |
Clean up and clarify instanceof_function_ex()
The instanceof_interface_only() function was dead code (always
returned zero).
Clarify that the last parameter indicates whether the passed CE
is interface or class and rewrite the code in terms of assertions.
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r-- | Zend/zend_operators.c | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 7c0c569164..bf896a8bef 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2309,22 +2309,6 @@ ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, } /* }}} */ -static zend_bool ZEND_FASTCALL instanceof_interface_only(const zend_class_entry *instance_ce, const zend_class_entry *ce) /* {{{ */ -{ - uint32_t i; - - if (instance_ce->num_interfaces) { - ZEND_ASSERT(instance_ce->ce_flags & ZEND_ACC_RESOLVED_INTERFACES); - for (i = 0; i < instance_ce->num_interfaces; i++) { - if (instanceof_interface_only(instance_ce->interfaces[i], ce)) { - return 1; - } - } - } - return 0; -} -/* }}} */ - static zend_always_inline zend_bool instanceof_class(const zend_class_entry *instance_ce, const zend_class_entry *ce) /* {{{ */ { while (instance_ce) { @@ -2353,21 +2337,16 @@ static zend_bool ZEND_FASTCALL instanceof_interface(const zend_class_entry *inst } /* }}} */ -ZEND_API zend_bool ZEND_FASTCALL instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only) /* {{{ */ +// TODO: It would make more sense to expose instanceof_class + instanceof_interface instead +ZEND_API zend_bool ZEND_FASTCALL instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool is_interface) /* {{{ */ { - if (ce->ce_flags & ZEND_ACC_INTERFACE) { - if (!interfaces_only) { - if (instanceof_interface_only(instance_ce, ce)) { - return 1; - } - } else { - return instanceof_interface(instance_ce, ce); - } - } - if (!interfaces_only) { + if (is_interface) { + ZEND_ASSERT(ce->ce_flags & ZEND_ACC_INTERFACE); + return instanceof_interface(instance_ce, ce); + } else { + ZEND_ASSERT(!(ce->ce_flags & ZEND_ACC_INTERFACE)); return instanceof_class(instance_ce, ce); } - return 0; } /* }}} */ |