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

table/parser: minor optimization of anon_fn names (#8851)

This commit is contained in:
yuyi 2021-02-20 21:54:47 +08:00 committed by GitHub
parent e8abda189a
commit 783cee98d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -564,7 +564,7 @@ fn (mut p Parser) anon_fn() ast.AnonFn {
is_variadic: is_variadic
return_type: return_type
}
name := 'anon_${p.tok.pos}_${p.table.fn_type_signature(func)}'
name := 'anon_fn_${p.table.fn_type_signature(func)}_$p.tok.pos'
func.name = name
idx := p.table.find_or_register_fn_type(p.mod, func, true, false)
typ := table.new_type(idx)

View File

@ -98,16 +98,16 @@ pub fn (t &Table) fn_type_signature(f &Fn) string {
for i, arg in f.params {
// TODO: for now ignore mut/pts in sig for now
typ := arg.typ.set_nr_muls(0)
// if arg.is_mut {
// sig += 'mut_'
// }
// sig += '$arg.typ'
sig += '$typ'
arg_type_sym := t.get_type_symbol(typ)
sig += '$arg_type_sym.kind'
if i < f.params.len - 1 {
sig += '_'
}
}
sig += '_$f.return_type'
if f.return_type != 0 && f.return_type != void_type {
sym := t.get_type_symbol(f.return_type)
sig += '__$sym.kind'
}
return sig
}