Simplify constant updating for properties

Instead of walking up the parent chain, use the scope stored in
the property info. This way we only need to walk one list of
property infos.
This commit is contained in:
Nikita Popov 2020-01-21 16:28:38 +01:00
parent 7cb1a706bb
commit 12fec7a14e

View file

@ -1030,7 +1030,6 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */
ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
{
if (!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
zend_class_entry *ce;
zend_class_constant *c;
zval *val;
zend_property_info *prop_info;
@ -1056,10 +1055,7 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
}
}
ce = class_type;
while (ce) {
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
if (prop_info->ce == ce) {
ZEND_HASH_FOREACH_PTR(&class_type->properties_info, prop_info) {
if (prop_info->flags & ZEND_ACC_STATIC) {
val = CE_STATIC_MEMBERS(class_type) + prop_info->offset;
} else {
@ -1070,7 +1066,7 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
zval tmp;
ZVAL_COPY(&tmp, val);
if (UNEXPECTED(zval_update_constant_ex(&tmp, ce) != SUCCESS)) {
if (UNEXPECTED(zval_update_constant_ex(&tmp, prop_info->ce) != SUCCESS)) {
zval_ptr_dtor(&tmp);
return FAILURE;
}
@ -1081,14 +1077,11 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
}
zval_ptr_dtor(val);
ZVAL_COPY_VALUE(val, &tmp);
} else if (UNEXPECTED(zval_update_constant_ex(val, ce) != SUCCESS)) {
} else if (UNEXPECTED(zval_update_constant_ex(val, prop_info->ce) != SUCCESS)) {
return FAILURE;
}
}
}
} ZEND_HASH_FOREACH_END();
ce = ce->parent;
}
class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
}