From 691880b22c1ebdf7b58a25e599d2ba41c72b1dfa Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Sun, 19 Jan 2020 13:44:13 -0500 Subject: [PATCH] Speed up unserializing object properties Hash table lookups are slow. Don't do one a second time to update the property. The call to zend_hash_update_ind goes back to 8b0deb8cd2d Background: Properties are IS_INDIRECT when they're a declared property, and point to properties_table. See https://nikic.github.io/2015/06/19/Internal-value-representation-in-PHP-7-part-2.html#objects-in-php-7 --- ext/standard/var_unserializer.re | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index feaccb2a50..c395f3cb5c 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -559,10 +559,13 @@ string_key: if ((old_data = zend_hash_find(ht, Z_STR(key))) != NULL) { if (Z_TYPE_P(old_data) == IS_INDIRECT) { + /* This is a property with a declaration */ old_data = Z_INDIRECT_P(old_data); info = zend_get_typed_property_info_for_slot(obj, old_data); var_push_dtor(var_hash, old_data); - data = zend_hash_update_ind(ht, Z_STR(key), &d); + Z_TRY_DELREF_P(old_data); + ZVAL_COPY_VALUE(old_data, &d); + data = old_data; if (UNEXPECTED(info)) { /* Remember to which property this slot belongs, so we can add a -- 2.50.1