com php-src: Avoid useless merge: Zend/zend_API.c Zend/ze nd_API.h ext/mysql/php_mysql.c ext/mysqli/mysqli. c ext/pgsql/pgsql.c
| From: | Dmitry Stogov | Date: | Tue, 03 Jun 2014 22:11:26 +0000 |
| Subject: | com php-src: Avoid useless merge: Zend/zend_API.c Zend/ze nd_API.h ext/mysql/php_mysql.c ext/mysqli/mysqli. c ext/pgsql/pgsql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78681@lists.php.net to get a copy of this message | ||
Commit: 6e7338700e8df8285c1d352b249e4970e35df472
Author: Dmitry Stogov <dmitry@zend.com> Wed, 4 Jun 2014 02:11:26 +0400
Parents: 3f6f0d5a700a7de777336569846fa2bfe23c667c
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6e7338700e8df8285c1d352b249e4970e35df472
Log:
Avoid useless merge
Changed paths:
M Zend/zend_API.c
M Zend/zend_API.h
M ext/mysql/php_mysql.c
M ext/mysqli/mysqli.c
M ext/pgsql/pgsql.c
Diff:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 2bafa85..45e2331 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 73152ca..0b96db8 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 580296a..588eaf0 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 7684e25..0d46831 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 3311196..4381440 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);