- Simplify

This commit is contained in:
Marcus Boerger 2006-02-06 01:30:26 +00:00
parent 9b8b9632cd
commit 42cc8c1ba3

View file

@ -819,18 +819,6 @@ zend_object_iterator *spl_array_obj_get_iterator(zend_class_entry *ce, zval *obj
} }
return NULL; return NULL;
} }
#if MBO_0
/* We enable by ref if the returned thing does. If it is an ArrayIterator */
/* or derived then it does if it's current() method is not overloaded. */
if (by_ref && ce_it && instanceof_function(ce_it, zend_ce_iterator TSRMLS_CC)) {
if (!ce_it->iterator_funcs.zf_current) {
zend_hash_find(&ce->function_table, "current", sizeof("current"), (void **) &ce_it->iterator_funcs.zf_current);
}
if (ce_it->iterator_funcs.zf_current->common.scope != spl_ce_ArrayObject) {
zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
}
}
#endif
new_iterator = ce_it->get_iterator(ce_it, iterator, by_ref TSRMLS_CC); new_iterator = ce_it->get_iterator(ce_it, iterator, by_ref TSRMLS_CC);
zval_ptr_dtor(&iterator); zval_ptr_dtor(&iterator);
@ -843,16 +831,10 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
spl_array_it *iterator; spl_array_it *iterator;
spl_array_object *array_object = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); spl_array_object *array_object = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
if (by_ref) { if (by_ref && (array_object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT)) {
if (!ce->iterator_funcs.zf_current) { zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
zend_hash_find(&ce->function_table, "current", sizeof("current"), (void **) &ce->iterator_funcs.zf_current);
}
if (array_object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT) {
zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
}
} }
iterator = emalloc(sizeof(spl_array_it)); iterator = emalloc(sizeof(spl_array_it));
object->refcount++; object->refcount++;