]> granicus.if.org Git - php/commitdiff
Speed up unserializing object properties
authorTyson Andre <tysonandre775@hotmail.com>
Sun, 19 Jan 2020 18:44:13 +0000 (13:44 -0500)
committerTyson Andre <tysonandre775@hotmail.com>
Mon, 20 Jan 2020 14:54:04 +0000 (09:54 -0500)
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

index feaccb2a50f9febe5ee122128ca20c2e09aa1713..c395f3cb5ca2eb74babdbb15393073b5b6f8f68b 100644 (file)
@@ -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