Skip to content

Commit c63a0e0

Browse files
committed
Optimize instanceof_class/interface
instanceof_class does not need to check for a NULL pointer in the first iteration -- passing NULL to this function is illegal. instanceof_interface does not need to use instanceof_class(), it only has to check whether the CEs match exactly. There is no way for an interface to appear inside "parent", it will always be in "interfaces" only.
1 parent 435f269 commit c63a0e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Zend/zend_operators.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,12 +2311,12 @@ ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1,
23112311

23122312
static zend_always_inline zend_bool instanceof_class(const zend_class_entry *instance_ce, const zend_class_entry *ce) /* {{{ */
23132313
{
2314-
while (instance_ce) {
2314+
do {
23152315
if (instance_ce == ce) {
23162316
return 1;
23172317
}
23182318
instance_ce = instance_ce->parent;
2319-
}
2319+
} while (instance_ce);
23202320
return 0;
23212321
}
23222322
/* }}} */
@@ -2333,7 +2333,7 @@ static zend_bool ZEND_FASTCALL instanceof_interface(const zend_class_entry *inst
23332333
}
23342334
}
23352335
}
2336-
return instanceof_class(instance_ce, ce);
2336+
return instance_ce == ce;
23372337
}
23382338
/* }}} */
23392339

0 commit comments

Comments
 (0)