1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Simplify handling of inheritance in SplFixedArray

After the loop, `parent` will for sure be ce_SplFixedArray, and
inherited will be true; for inherited cases.
This commit is contained in:
Niels Dossche
2025-03-30 20:49:13 +02:00
parent 9e52d1698a
commit d20e3e6cb1

View File

@@ -278,7 +278,6 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
{
spl_fixedarray_object *intern;
zend_class_entry *parent = class_type;
bool inherited = false;
intern = zend_object_alloc(sizeof(spl_fixedarray_object), parent);
@@ -290,21 +289,10 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
spl_fixedarray_copy_ctor(&intern->array, &other->array);
}
while (parent) {
if (parent == spl_ce_SplFixedArray) {
break;
}
parent = parent->parent;
inherited = true;
}
ZEND_ASSERT(parent);
if (UNEXPECTED(inherited)) {
if (UNEXPECTED(class_type != spl_ce_SplFixedArray)) {
/* Find count() method */
zend_function *fptr_count = zend_hash_find_ptr(&class_type->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
if (fptr_count->common.scope == parent) {
if (fptr_count->common.scope == spl_ce_SplFixedArray) {
fptr_count = NULL;
}
intern->fptr_count = fptr_count;