Skip to content

Commit c04ab75

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 53b0823 commit c04ab75

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,23 +289,12 @@ 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
intern->std.handlers = &spl_handler_SplFixedArray_proxied;
306294

307295
/* Find count() method */
308296
zend_function *fptr_count = zend_hash_find_ptr(&class_type->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
309-
if (fptr_count->common.scope == parent) {
297+
if (fptr_count->common.scope == spl_ce_SplFixedArray) {
310298
fptr_count = NULL;
311299
}
312300
intern->fptr_count = fptr_count;

0 commit comments

Comments
 (0)