[php-src] PR #12474: Avoid refcounted copy in _object_properties_init() for internal classes
| From: | nielsdos | Date: | Wed, 18 Oct 2023 23:41:15 +0000 |
| Subject: | [php-src] PR #12474: Avoid refcounted copy in _object_properties_init() for internal classes | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-23934@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12474
Author: nielsdos
This currently uses ZVAL_COPY_OR_DUP, which copies the value and handles refcounting. However,
internal classes cannot have refcounted default properties because of constraints imposed by
zend_declare_typed_property(). So copying the value is sufficient.
While this doesn't really improve the performance for our benchmarks, it improves performance
for cases where a lot of temporary internal objects are instantiated. For example, when
instantiating DOM classes: DOM objects are transient, so lots of temporary objects are created.
I have a variant on my fork that adds a CE flag to extend this to user classes too
(https://github.com/nielsdos/php-src/pull/55). But the performance win is so small that I'm not
convinced that's useful.