From: Nikita Popov Date: Tue, 7 Apr 2020 14:10:19 +0000 (+0200) Subject: Optimize internal name fetching in reflection X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=425c6f5815ea8ffbf5b73d684bd931551c200d26;p=php Optimize internal name fetching in reflection Directly fetch the name property, instead of construction the properties hash table and performing a lookup in it. This is both slow and wastes a lot of memory. --- diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index e9993e9feb..82b1b3d68c 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -172,7 +172,11 @@ static inline zend_bool is_closure_invoke(zend_class_entry *ce, zend_string *lcn static zval *_default_load_name(zval *object) /* {{{ */ { - return zend_hash_find_ex_ind(Z_OBJPROP_P(object), ZSTR_KNOWN(ZEND_STR_NAME), 1); + zval *name = reflection_prop_name(object); + if (Z_ISUNDEF_P(name)) { + return NULL; + } + return name; } /* }}} */