diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-06-04 02:11:26 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-06-04 02:11:26 +0400 |
commit | 6e7338700e8df8285c1d352b249e4970e35df472 (patch) | |
tree | 4e62ee6a549b063620ab24f7d7bcd929927f5e77 | |
parent | 3f6f0d5a700a7de777336569846fa2bfe23c667c (diff) | |
download | php-git-6e7338700e8df8285c1d352b249e4970e35df472.tar.gz |
Avoid useless merge
-rw-r--r-- | Zend/zend_API.c | 7 | ||||
-rw-r--r-- | Zend/zend_API.h | 2 | ||||
-rw-r--r-- | ext/mysql/php_mysql.c | 10 | ||||
-rw-r--r-- | ext/mysqli/mysqli.c | 10 | ||||
-rw-r--r-- | ext/pgsql/pgsql.c | 10 |
5 files changed, 26 insertions, 13 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 2bafa8586a..45e2331518 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1097,7 +1097,7 @@ ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC) /* {{{ */ /* This function should be called after the constructor has been called * because it may call __set from the uninitialized object otherwise. */ -ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destroy_ht TSRMLS_DC) /* {{{ */ +ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC) /* {{{ */ { const zend_object_handlers *obj_ht = Z_OBJ_HT_P(obj); zend_class_entry *old_scope = EG(scope); @@ -1115,11 +1115,6 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destro } } ZEND_HASH_FOREACH_END(); EG(scope) = old_scope; - - if (destroy_ht) { - zend_hash_destroy(properties); - FREE_HASHTABLE(properties); - } } /* }}} */ diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 73152caa1c..0b96db84f1 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -370,7 +370,7 @@ ZEND_API void object_properties_init(zend_object *object, zend_class_entry *clas ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties TSRMLS_DC); ZEND_API void object_properties_load(zend_object *object, HashTable *properties TSRMLS_DC); -ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destroy_ht TSRMLS_DC); +ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC); /* no longer supported */ ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS)); diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 580296a3cf..588eaf0539 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -2171,8 +2171,14 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, ZVAL_COPY_VALUE(&dataset, return_value); object_and_properties_init(return_value, ce, NULL); - zend_merge_properties(return_value, Z_ARRVAL(dataset), 0 TSRMLS_CC); - zval_dtor(&dataset); + if (!ce->default_properties_count && !ce->__set) { + ALLOC_HASHTABLE(Z_OBJ_P(return_value)->properties); + *Z_OBJ_P(return_value)->properties = *Z_ARRVAL(dataset); + efree(Z_ARR(dataset)); + } else { + zend_merge_properties(return_value, Z_ARRVAL(dataset) TSRMLS_CC); + zval_dtor(&dataset); + } if (ce->constructor) { fci.size = sizeof(fci); diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 7684e25765..0d4683102a 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1287,8 +1287,14 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags ZVAL_COPY_VALUE(&dataset, return_value); object_and_properties_init(return_value, ce, NULL); - zend_merge_properties(return_value, Z_ARRVAL(dataset), 0 TSRMLS_CC); - zval_ptr_dtor(&dataset); + if (!ce->default_properties_count && !ce->__set) { + ALLOC_HASHTABLE(Z_OBJ_P(return_value)->properties); + *Z_OBJ_P(return_value)->properties = *Z_ARRVAL(dataset); + efree(Z_ARR(dataset)); + } else { + zend_merge_properties(return_value, Z_ARRVAL(dataset) TSRMLS_CC); + zval_ptr_dtor(&dataset); + } if (ce->constructor) { fci.size = sizeof(fci); diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 3311196638..4381440e8d 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2752,8 +2752,14 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, ZVAL_COPY_VALUE(&dataset, return_value); object_and_properties_init(return_value, ce, NULL); - zend_merge_properties(return_value, Z_ARRVAL(dataset), 0 TSRMLS_CC); - zval_ptr_dtor(&dataset); + if (!ce->default_properties_count && !ce->__set) { + ALLOC_HASHTABLE(Z_OBJ_P(return_value)->properties); + *Z_OBJ_P(return_value)->properties = *Z_ARRVAL(dataset); + efree(Z_ARR(dataset)); + } else { + zend_merge_properties(return_value, Z_ARRVAL(dataset) TSRMLS_CC); + zval_ptr_dtor(&dataset); + } if (ce->constructor) { fci.size = sizeof(fci); |