mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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:
parent
7cb1a706bb
commit
12fec7a14e
1 changed files with 24 additions and 31 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue