]> granicus.if.org Git - php/commitdiff
Speedup array/HashTable copying. (Matt W)
authorDmitry Stogov <dmitry@php.net>
Tue, 3 Oct 2006 11:10:33 +0000 (11:10 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 3 Oct 2006 11:10:33 +0000 (11:10 +0000)
NEWS
Zend/zend_API.c
Zend/zend_compile.c
Zend/zend_variables.c

diff --git a/NEWS b/NEWS
index cabb18e6340f77e7b80d2046f937cac35647f586..4e696cacbf5a998f4fe7dd89332d5e37c07ae428 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Sep 2006, PHP 5.2.0
+- Speedup array/HashTable copying. (Matt W, Dmitry)
 - Added ability to make SOAP call userspace PHP<->XML converters. (Dmitry)
 - Fixed infinite loop when a wrong color index is given to imagefill (Pierre)
 - Fixed mess with CGI/CLI -d option (now it works with cgi; constants are
index e90807fc6d084cbb17d21192b88882c06a5bf5cf..117d14a751e3ab8cd0c50719e9b31af3294b9b83 100644 (file)
@@ -882,7 +882,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC
 #else
                        ALLOC_HASHTABLE(class_type->static_members);
 #endif
-                       zend_hash_init(CE_STATIC_MEMBERS(class_type), 0, NULL, ZVAL_PTR_DTOR, 0);
+                       zend_hash_init(CE_STATIC_MEMBERS(class_type), zend_hash_num_elements(&class_type->default_static_members), NULL, ZVAL_PTR_DTOR, 0);
 
                        zend_hash_internal_pointer_reset_ex(&class_type->default_static_members, &pos);
                        while (zend_hash_get_current_data_ex(&class_type->default_static_members, (void**)&p, &pos) == SUCCESS) {
@@ -943,7 +943,7 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type
                        object->properties = properties;
                } else {
                        ALLOC_HASHTABLE_REL(object->properties);
-                       zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+                       zend_hash_init(object->properties, zend_hash_num_elements(&class_type->default_properties), NULL, ZVAL_PTR_DTOR, 0);
                        zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
                }
        } else {
index 191d8dfe945d6d5e0dc2ea7c7499a9ec7694a459..86b0013816aa7aa7f9965b200adad39af28843b3 100644 (file)
@@ -1796,7 +1796,7 @@ ZEND_API void function_add_ref(zend_function *function)
                        zval *tmp_zval;
 
                        ALLOC_HASHTABLE(op_array->static_variables);
-                       zend_hash_init(op_array->static_variables, 2, NULL, ZVAL_PTR_DTOR, 0);
+                       zend_hash_init(op_array->static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0);
                        zend_hash_copy(op_array->static_variables, static_variables, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *));
                }
        }
index ca24c3d6fbdc5301b53076ed2f3a84b746b4e218..0b7143ac4b2776dceb2addc23137b4416951f492 100644 (file)
@@ -130,7 +130,7 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
                                        return; /* do nothing */
                                }
                                ALLOC_HASHTABLE_REL(tmp_ht);
-                               zend_hash_init(tmp_ht, 0, NULL, ZVAL_PTR_DTOR, 0);
+                               zend_hash_init(tmp_ht, zend_hash_num_elements(original_ht), NULL, ZVAL_PTR_DTOR, 0);
                                zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
                                zvalue->value.ht = tmp_ht;
                        }