Skip to content

Commit 691880b

Browse files
committed
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 8b0deb8 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
1 parent 0fbdc5a commit 691880b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/standard/var_unserializer.re

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,13 @@ string_key:
559559

560560
if ((old_data = zend_hash_find(ht, Z_STR(key))) != NULL) {
561561
if (Z_TYPE_P(old_data) == IS_INDIRECT) {
562+
/* This is a property with a declaration */
562563
old_data = Z_INDIRECT_P(old_data);
563564
info = zend_get_typed_property_info_for_slot(obj, old_data);
564565
var_push_dtor(var_hash, old_data);
565-
data = zend_hash_update_ind(ht, Z_STR(key), &d);
566+
Z_TRY_DELREF_P(old_data);
567+
ZVAL_COPY_VALUE(old_data, &d);
568+
data = old_data;
566569

567570
if (UNEXPECTED(info)) {
568571
/* Remember to which property this slot belongs, so we can add a

0 commit comments

Comments
 (0)