Skip to content

Commit 425c6f5

Browse files
committed
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.
1 parent c81cf1c commit 425c6f5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ static inline zend_bool is_closure_invoke(zend_class_entry *ce, zend_string *lcn
172172

173173
static zval *_default_load_name(zval *object) /* {{{ */
174174
{
175-
return zend_hash_find_ex_ind(Z_OBJPROP_P(object), ZSTR_KNOWN(ZEND_STR_NAME), 1);
175+
zval *name = reflection_prop_name(object);
176+
if (Z_ISUNDEF_P(name)) {
177+
return NULL;
178+
}
179+
return name;
176180
}
177181
/* }}} */
178182

0 commit comments

Comments
 (0)