mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
markused: clean up map fns handling (#24998)
This commit is contained in:
parent
eb99497ffc
commit
6915a5a1b5
@ -359,41 +359,6 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
|
|||||||
walker.used_fns.delete('${int(ast.none_type)}.str')
|
walker.used_fns.delete('${int(ast.none_type)}.str')
|
||||||
}
|
}
|
||||||
|
|
||||||
if table.used_features.used_maps > 0 {
|
|
||||||
for k, mut mfn in all_fns {
|
|
||||||
mut method_receiver_typename := ''
|
|
||||||
if mfn.is_method {
|
|
||||||
method_receiver_typename = table.type_to_str(mfn.receiver.typ)
|
|
||||||
}
|
|
||||||
if k in ['new_map', 'new_map_init', 'map_hash_string']
|
|
||||||
|| method_receiver_typename == '&map' || method_receiver_typename == '&DenseArray'
|
|
||||||
|| k.starts_with('map_') {
|
|
||||||
walker.fn_decl(mut mfn)
|
|
||||||
}
|
|
||||||
if pref_.gc_mode in [.boehm_full_opt, .boehm_incr_opt] {
|
|
||||||
if k in ['new_map_noscan_key', 'new_map_noscan_value', 'new_map_noscan_key_value',
|
|
||||||
'new_map_init_noscan_key', 'new_map_init_noscan_value',
|
|
||||||
'new_map_init_noscan_key_value'] {
|
|
||||||
walker.fn_decl(mut mfn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for map_fn_name in ['new_map', 'new_map_init', 'map_hash_string', 'new_dense_array',
|
|
||||||
'new_dense_array_noscan'] {
|
|
||||||
walker.used_fns.delete(map_fn_name)
|
|
||||||
}
|
|
||||||
for k, mut mfn in all_fns {
|
|
||||||
if !mfn.is_method {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
method_receiver_typename := table.type_to_str(mfn.receiver.typ)
|
|
||||||
if method_receiver_typename in ['&map', '&mapnode', '&SortedMap', '&DenseArray'] {
|
|
||||||
walker.used_fns.delete(k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table.used_features.used_fns = walker.used_fns.move()
|
table.used_features.used_fns = walker.used_fns.move()
|
||||||
table.used_features.used_consts = walker.used_consts.move()
|
table.used_features.used_consts = walker.used_consts.move()
|
||||||
table.used_features.used_globals = walker.used_globals.move()
|
table.used_features.used_globals = walker.used_globals.move()
|
||||||
|
@ -1313,6 +1313,7 @@ fn (mut w Walker) mark_resource_dependencies() {
|
|||||||
eprintln('>>>>>>>>>> ALL_FNS LOOP')
|
eprintln('>>>>>>>>>> ALL_FNS LOOP')
|
||||||
}
|
}
|
||||||
mut has_ptr_print := false
|
mut has_ptr_print := false
|
||||||
|
mut map_fns := map[string]ast.FnDecl{}
|
||||||
has_str_call := w.uses_interp || w.uses_asserts || w.uses_str.len > 0
|
has_str_call := w.uses_interp || w.uses_asserts || w.uses_str.len > 0
|
||||||
|| w.features.print_types.len > 0
|
|| w.features.print_types.len > 0
|
||||||
for k, mut func in w.all_fns {
|
for k, mut func in w.all_fns {
|
||||||
@ -1349,6 +1350,50 @@ fn (mut w Walker) mark_resource_dependencies() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if func.is_method && !func.receiver.typ.has_flag(.generic) && func.receiver.typ.is_ptr() {
|
||||||
|
method_receiver_typename := w.table.type_to_str(func.receiver.typ)
|
||||||
|
if method_receiver_typename in ['&map', '&mapnode', '&SortedMap', '&DenseArray'] {
|
||||||
|
map_fns[k] = func
|
||||||
|
}
|
||||||
|
} else if k.starts_with('map_') {
|
||||||
|
map_fns[k] = func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if w.features.used_maps > 0 {
|
||||||
|
w.fn_by_name('new_map')
|
||||||
|
w.fn_by_name('new_map_init')
|
||||||
|
w.fn_by_name('map_hash_string')
|
||||||
|
|
||||||
|
if w.pref.gc_mode in [.boehm_full_opt, .boehm_incr_opt] {
|
||||||
|
w.fn_by_name('new_map_noscan_key')
|
||||||
|
w.fn_by_name('new_map_noscan_value')
|
||||||
|
w.fn_by_name('new_map_noscan_key_value')
|
||||||
|
w.fn_by_name('new_map_init_noscan_key')
|
||||||
|
w.fn_by_name('new_map_init_noscan_value')
|
||||||
|
w.fn_by_name('new_map_init_noscan_key_value')
|
||||||
|
}
|
||||||
|
for _, mut func in map_fns {
|
||||||
|
if !func.is_method {
|
||||||
|
w.fn_decl(mut func)
|
||||||
|
} else {
|
||||||
|
method_receiver_typename := w.table.type_to_str(func.receiver.typ)
|
||||||
|
if method_receiver_typename in ['&map', '&DenseArray'] {
|
||||||
|
w.fn_decl(mut func)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for k, func in map_fns {
|
||||||
|
if !func.is_method {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
w.used_fns.delete(k)
|
||||||
|
}
|
||||||
|
w.used_fns.delete('new_map')
|
||||||
|
w.used_fns.delete('new_map_init')
|
||||||
|
w.used_fns.delete('map_hash_string')
|
||||||
|
w.used_fns.delete('new_dense_array')
|
||||||
|
w.used_fns.delete('new_dense_array_noscan')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user