1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

table: optimize fn_type_signature() (#16552)

This commit is contained in:
yuyi 2022-11-29 19:13:58 +08:00 committed by GitHub
parent 58e150df12
commit dff61300fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -213,16 +213,11 @@ pub fn set_global_table(t &Table) {
pub fn (t &Table) fn_type_signature(f &Fn) string {
mut sig := ''
for i, arg in f.params {
// TODO: for now ignore mut/pts in sig for now
typ := arg.typ.set_nr_muls(0)
arg_type_sym := t.sym(typ)
if arg_type_sym.kind == .alias {
sig += arg_type_sym.cname
} else {
sig += arg_type_sym.str().to_lower().replace_each(['.', '__', '&', '', '[', 'arr_',
'chan ', 'chan_', 'map[', 'map_of_', ']', '_to_', '<', '_T_', ',', '_', ' ', '',
'>', '', '(', '_', ')', '_'])
if arg.is_mut {
sig += 'mut_'
}
sig += t.sym(typ).cname.to_lower()
if i < f.params.len - 1 {
sig += '_'
}