diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-06-17 12:50:16 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-06-17 12:50:16 +0300 |
commit | 4a6e1345e2dfd1d1edfd18b783bc9000598a4d92 (patch) | |
tree | 05b52f5393e38d86e1a738696a63143289c8f25d /Zend/zend_operators.c | |
parent | e011e6fdf4a7b65d4cf92dcad57f1e4fe4b25b80 (diff) | |
download | php-git-4a6e1345e2dfd1d1edfd18b783bc9000598a4d92.tar.gz |
Use COW to prevent unnecessary duplication of dynamic propertyes of stdClass (and other classes without predefined properties).
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r-- | Zend/zend_operators.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index d7d2591382..7e3b458bbe 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -588,9 +588,24 @@ try_again: HashTable *obj_ht = Z_OBJ_HT_P(op)->get_properties(op); if (obj_ht) { zval arr; - ZVAL_ARR(&arr, zend_array_dup(obj_ht)); - zval_dtor(op); - ZVAL_COPY_VALUE(op, &arr); + + if (!Z_OBJCE_P(op)->default_properties_count && obj_ht == Z_OBJ_P(op)->properties) { + /* fast copy */ + if (EXPECTED(Z_OBJ_P(op)->handlers == &std_object_handlers)) { + ZVAL_ARR(&arr, obj_ht); + if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(op)->properties) & IS_ARRAY_IMMUTABLE))) { + GC_REFCOUNT(Z_OBJ_P(op)->properties)++; + } + } else { + ZVAL_ARR(&arr, zend_array_dup(obj_ht)); + } + zval_dtor(op); + ZVAL_COPY_VALUE(op, &arr); + } else { + ZVAL_ARR(&arr, zend_array_dup(obj_ht)); + zval_dtor(op); + ZVAL_COPY_VALUE(op, &arr); + } return; } } else { |