1
0
mirror of https://github.com/php/php-src.git synced 2026-04-14 19:41:05 +02:00

Prevent call of var_push_dtor_value() on hot path.

When serialising object properties, they are oftet may override the
default values, however default values are most often scalars, interned
strings or immutable arrays.
This commit is contained in:
Dmitry Stogov
2021-04-09 00:40:17 +03:00
parent d8e4fbae62
commit 556d752667

View File

@@ -618,18 +618,22 @@ declared_property:
(*var_hash)->ref_props, (zend_uintptr_t) data);
}
}
var_push_dtor_value(var_hash, data);
/* We may override default property value, but they are usually immutable */
if (Z_REFCOUNTED_P(data)) {
var_push_dtor_value(var_hash, data);
}
ZVAL_NULL(data);
} else {
/* Unusual override of dynamic property */
int ret = is_property_visibility_changed(obj->ce, &key);
if (EXPECTED(!ret)) {
if (ret > 0) {
goto second_try;
} else if (!ret) {
var_push_dtor_value(var_hash, data);
ZVAL_NULL(data);
} else if (ret < 0) {
goto failure;
} else {
goto second_try;
}
}
} else {
@@ -644,7 +648,7 @@ second_try:
data = zend_hash_lookup(ht, Z_STR(key));
if (Z_TYPE_P(data) == IS_INDIRECT) {
goto declared_property;
} else if (UNEXPECTED(Z_TYPE_P(data) != IS_NULL)) {
} else if (UNEXPECTED(Z_TYPE_INFO_P(data) != IS_NULL)) {
var_push_dtor_value(var_hash, data);
ZVAL_NULL(data);
}