diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-11-06 14:50:03 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-11-06 14:50:03 +0300 |
commit | 75041379a6e73b22c094c3c9c7878a1c4e439725 (patch) | |
tree | 7266d09071014b1a0b52e01113a407450b987d8e /Zend/zend_API.c | |
parent | 6b8328de740ce0bc116f322be5193b6b7b83927f (diff) | |
download | php-git-75041379a6e73b22c094c3c9c7878a1c4e439725.tar.gz |
Improved object property access.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3643bfc8e2..e22b557451 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1207,7 +1207,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC for (i = 0; i < class_type->default_properties_count; i++) { if (Z_TYPE(class_type->default_properties_table[i]) != IS_UNDEF) { - zval_update_class_constant(&class_type->default_properties_table[i], 0, i TSRMLS_CC); + zval_update_class_constant(&class_type->default_properties_table[i], 0, OBJ_PROP_TO_OFFSET(i) TSRMLS_CC); } } @@ -1251,8 +1251,9 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info && (property_info->flags & ZEND_ACC_STATIC) == 0) { - ZVAL_COPY_VALUE(&object->properties_table[property_info->offset], prop); - ZVAL_INDIRECT(prop, &object->properties_table[property_info->offset]); + zval *slot = OBJ_PROP(object, property_info->offset); + ZVAL_COPY_VALUE(slot, prop); + ZVAL_INDIRECT(prop, slot); } } ZEND_HASH_FOREACH_END(); } @@ -1270,11 +1271,12 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info && (property_info->flags & ZEND_ACC_STATIC) == 0) { - zval_ptr_dtor(&object->properties_table[property_info->offset]); - ZVAL_COPY_VALUE(&object->properties_table[property_info->offset], prop); - zval_add_ref(&object->properties_table[property_info->offset]); + zval *slot = OBJ_PROP(object, property_info->offset); + zval_ptr_dtor(slot); + ZVAL_COPY_VALUE(slot, prop); + zval_add_ref(slot); if (object->properties) { - ZVAL_INDIRECT(&tmp, &object->properties_table[property_info->offset]); + ZVAL_INDIRECT(&tmp, slot); zend_hash_update(object->properties, key, &tmp); } } else { @@ -3618,13 +3620,14 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL && (property_info_ptr->flags & ZEND_ACC_STATIC) == 0) { property_info->offset = property_info_ptr->offset; - zval_ptr_dtor(&ce->default_properties_table[property_info->offset]); + zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]); zend_hash_del(&ce->properties_info, name); } else { - property_info->offset = ce->default_properties_count++; + property_info->offset = OBJ_PROP_TO_OFFSET(ce->default_properties_count); + ce->default_properties_count++; ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval) * ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS); } - ZVAL_COPY_VALUE(&ce->default_properties_table[property_info->offset], property); + ZVAL_COPY_VALUE(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)], property); } if (ce->type & ZEND_INTERNAL_CLASS) { switch(Z_TYPE_P(property)) { |