Commit 13bf672cdb1 for php.net
commit 13bf672cdb1bcd9684225f6f0473c071434bdc8c
Author: Niels Dossche <7771979+ndossche@users.noreply.github.com>
Date: Fri Nov 28 19:03:22 2025 +0100
reflection: Use zend_hash_str_find_ptr_lc() where possible
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 05454b24c4e..4cf3edd4737 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1432,13 +1432,7 @@ static void reflection_extension_factory_ex(zval *object, zend_module_entry *mod
static void reflection_extension_factory(zval *object, const char *name_str)
{
size_t name_len = strlen(name_str);
- zend_string *lcname;
- struct _zend_module_entry *module;
-
- lcname = zend_string_alloc(name_len, 0);
- zend_str_tolower_copy(ZSTR_VAL(lcname), name_str, name_len);
- module = zend_hash_find_ptr(&module_registry, lcname);
- zend_string_efree(lcname);
+ struct _zend_module_entry *module = zend_hash_str_find_ptr_lc(&module_registry, name_str, name_len);
if (!module) {
return;
}
@@ -6643,12 +6637,10 @@ ZEND_METHOD(ReflectionProperty, isFinal)
ZEND_METHOD(ReflectionExtension, __construct)
{
zval *object;
- char *lcname;
reflection_object *intern;
zend_module_entry *module;
char *name_str;
size_t name_len;
- ALLOCA_FLAG(use_heap)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
RETURN_THROWS();
@@ -6656,15 +6648,11 @@ ZEND_METHOD(ReflectionExtension, __construct)
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
- lcname = do_alloca(name_len + 1, use_heap);
- zend_str_tolower_copy(lcname, name_str, name_len);
- if ((module = zend_hash_str_find_ptr(&module_registry, lcname, name_len)) == NULL) {
- free_alloca(lcname, use_heap);
+ if ((module = zend_hash_str_find_ptr_lc(&module_registry, name_str, name_len)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Extension \"%s\" does not exist", name_str);
RETURN_THROWS();
}
- free_alloca(lcname, use_heap);
zval *prop_name = reflection_prop_name(object);
zval_ptr_dtor(prop_name);
ZVAL_STRING(prop_name, module->name);