Skip to content

Commit d20e3e6

Browse files
committed
Simplify handling of inheritance in SplFixedArray
After the loop, `parent` will for sure be ce_SplFixedArray, and inherited will be true; for inherited cases.
1 parent 9e52d16 commit d20e3e6

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

ext/spl/spl_fixedarray.c

+2-14
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
278278
{
279279
spl_fixedarray_object *intern;
280280
zend_class_entry *parent = class_type;
281-
bool inherited = false;
282281

283282
intern = zend_object_alloc(sizeof(spl_fixedarray_object), parent);
284283

@@ -290,21 +289,10 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
290289
spl_fixedarray_copy_ctor(&intern->array, &other->array);
291290
}
292291

293-
while (parent) {
294-
if (parent == spl_ce_SplFixedArray) {
295-
break;
296-
}
297-
298-
parent = parent->parent;
299-
inherited = true;
300-
}
301-
302-
ZEND_ASSERT(parent);
303-
304-
if (UNEXPECTED(inherited)) {
292+
if (UNEXPECTED(class_type != spl_ce_SplFixedArray)) {
305293
/* Find count() method */
306294
zend_function *fptr_count = zend_hash_find_ptr(&class_type->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
307-
if (fptr_count->common.scope == parent) {
295+
if (fptr_count->common.scope == spl_ce_SplFixedArray) {
308296
fptr_count = NULL;
309297
}
310298
intern->fptr_count = fptr_count;

0 commit comments

Comments
 (0)