@@ -1981,16 +1981,23 @@ static void zend_resolve_trait_relative_class_types(zend_function *const fn, con
1981
1981
/* Variadic parameters are not counted as part of the standard number of arguments */
1982
1982
bool has_variadic_type = fn -> common .fn_flags & ZEND_ACC_VARIADIC ;
1983
1983
uint32_t num_args = fn -> common .num_args + has_variadic_type ;
1984
- /* TODO Only do allocation if need to resolve types, as arg_info is stored in SHM */
1985
1984
size_t allocated_size = sizeof (zend_arg_info ) * (has_return_type + num_args );
1986
1985
1987
- zend_arg_info * new_arg_infos = zend_arena_alloc (& CG (arena ), allocated_size );
1988
- memcpy (new_arg_infos , fn -> common .arg_info - has_return_type , allocated_size );
1989
- fn -> common .arg_info = new_arg_infos + has_return_type ;
1986
+ zend_arg_info * new_arg_infos = fn -> common .arg_info - has_return_type ;
1987
+ bool has_resolved_type = false;
1990
1988
1991
1989
for (uint32_t i = 0 ; i < num_args + has_return_type ; i ++ ) {
1992
1990
zend_type type = new_arg_infos [i ].type ;
1993
- new_arg_infos [i ].type = zend_resolve_single_type (type , ce );
1991
+ zend_type resolved_type = zend_resolve_single_type (type , ce );
1992
+ if (type .ptr != resolved_type .ptr ) {
1993
+ if (!has_resolved_type ) {
1994
+ new_arg_infos = zend_arena_alloc (& CG (arena ), allocated_size );
1995
+ memcpy (new_arg_infos , fn -> common .arg_info - has_return_type , allocated_size );
1996
+ fn -> common .arg_info = new_arg_infos + has_return_type ;
1997
+ has_resolved_type = true;
1998
+ }
1999
+ new_arg_infos [i ].type = resolved_type ;
2000
+ }
1994
2001
}
1995
2002
}
1996
2003
0 commit comments