]> granicus.if.org Git - php/commitdiff
Optimize internal name fetching in reflection
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Apr 2020 14:10:19 +0000 (16:10 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Apr 2020 14:10:19 +0000 (16:10 +0200)
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.

ext/reflection/php_reflection.c

index e9993e9feb2ac27b30161000404bef7b747c0b6e..82b1b3d68c06eb77ba693ac63a3d268041204317 100644 (file)
@@ -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;
 }
 /* }}} */