diff options
author | Zeev Suraski <zeev@php.net> | 1999-11-21 18:11:10 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 1999-11-21 18:11:10 +0000 |
commit | 6358c6631b278ffbb733a5d1eabd6f4101712509 (patch) | |
tree | e01ccb7c1762ab482241e32b290974b6b417afa2 /Zend | |
parent | 5cc10ecec231640ea903992c9c84aa110441a211 (diff) | |
download | php-git-6358c6631b278ffbb733a5d1eabd6f4101712509.tar.gz |
- Optimize class instanciation
- Fix constant instanciation for array elements inside objects
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend.h | 1 | ||||
-rw-r--r-- | Zend/zend_API.c | 14 | ||||
-rw-r--r-- | Zend/zend_compile.c | 1 | ||||
-rw-r--r-- | Zend/zend_execute.h | 2 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 7 |
5 files changed, 14 insertions, 11 deletions
diff --git a/Zend/zend.h b/Zend/zend.h index 429f9fae79..313f151be1 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -160,6 +160,7 @@ struct _zend_class_entry { uint name_length; struct _zend_class_entry *parent; int *refcount; + zend_bool constants_updated; HashTable function_table; HashTable default_properties; diff --git a/Zend/zend_API.c b/Zend/zend_API.c index fdcda0c5be..81bf12a894 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -199,21 +199,17 @@ ZEND_API inline int array_init(zval *arg) } -static void zval_update_const_and_ref(zval **p) -{ - zval_update_constant(*p); - zval_add_ref(p); -} - - - ZEND_API inline int object_init_ex(zval *arg, zend_class_entry *class_type) { zval *tmp; + if (!class_type->constants_updated) { + zend_hash_apply(&class_type->default_properties, (int (*)(void *)) zval_update_constant); + class_type->constants_updated = 1; + } arg->value.obj.properties = (HashTable *) emalloc(sizeof(HashTable)); zend_hash_init(arg->value.obj.properties, 0, NULL, PVAL_PTR_DTOR, 0); - zend_hash_copy(arg->value.obj.properties, &class_type->default_properties, (void (*)(void *)) zval_update_const_and_ref, (void *) &tmp, sizeof(zval *)); + zend_hash_copy(arg->value.obj.properties, &class_type->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *)); arg->type = IS_OBJECT; arg->value.obj.ce = class_type; return SUCCESS; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c5483d19ee..f33593619e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1384,6 +1384,7 @@ void do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_ CG(class_entry).name_length = class_name->u.constant.value.str.len; CG(class_entry).refcount = (int *) emalloc(sizeof(int)); *CG(class_entry).refcount = 1; + CG(class_entry).constants_updated = 0; zend_str_tolower(CG(class_entry).name, CG(class_entry).name_length); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index ae984990c8..84296c089d 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -49,7 +49,7 @@ ZEND_API int zend_is_true(zval *op); ZEND_API inline void safe_free_zval_ptr(zval *p); ZEND_API void zend_eval_string(char *str, zval *retval CLS_DC ELS_DC); ZEND_API inline int i_zend_is_true(zval *op); -ZEND_API void zval_update_constant(zval *p); +ZEND_API int zval_update_constant(zval **pp); ZEND_API inline void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts ELS_DC); /* dedicated Zend executor functions - do not use! */ diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 19b8e4b6ed..43ce0868bd 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -260,8 +260,10 @@ ZEND_API int zend_is_true(zval *op) } -ZEND_API void zval_update_constant(zval *p) +ZEND_API int zval_update_constant(zval **pp) { + zval *p = *pp; + if (p->type == IS_CONSTANT) { zval c; int refcount = p->refcount; @@ -277,7 +279,10 @@ ZEND_API void zval_update_constant(zval *p) } INIT_PZVAL(p); p->refcount = refcount; + } else if (p->type == IS_ARRAY) { + zend_hash_apply(p->value.ht, (int (*)(void *)) zval_update_constant); } + return 0; } |