Skip to content

Commit

Permalink
opt
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 20, 2025
1 parent 4800a60 commit f2f0dfe
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions vlib/v/markused/markused.v
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,10 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
all_fn_root_names << k
continue
}
has_dot := k.contains('.')
// auto generated string interpolation functions, may
// call .str or .auto_str methods for user types:
if k.ends_with('.str') || k.ends_with('.auto_str')
if (has_dot && (k.ends_with('.str') || k.ends_with('.auto_str')))
|| (k.starts_with('_Atomic_') && k.ends_with('_str')) {
if table.used_features.auto_str || table.used_features.dump
|| table.used_features.print_types[mfn.receiver.typ.idx()]
Expand All @@ -294,23 +295,29 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
}
continue
}
if k.ends_with('.init') || k.ends_with('.cleanup') {
all_fn_root_names << k
continue
}
if (pref_.autofree || table.used_features.external_types) && k.ends_with('.free') {
all_fn_root_names << k
continue
}

// sync:
if k in ['sync.new_channel_st', 'sync.channel_select'] {
all_fn_root_names << k
continue
}
if pref_.is_prof {
if k.starts_with('time.vpc_now') || k.starts_with('v.profile.') {
// needed for -profile
if has_dot {
if k.ends_with('.init') || k.ends_with('.cleanup') {
all_fn_root_names << k
continue
}
// sync:
if k in ['sync.new_channel_st', 'sync.channel_select'] {
all_fn_root_names << k
continue
}
if pref_.is_prof {
if k.starts_with('time.vpc_now') || k.starts_with('v.profile.') {
// needed for -profile
all_fn_root_names << k
continue
}
}
if (pref_.autofree || table.used_features.external_types) && k.ends_with('.free') {
all_fn_root_names << k
continue
}
if has_dot && (k.ends_with('.lock') || k.ends_with('.unlock')
|| k.ends_with('.rlock') || k.ends_with('.runlock')) {
all_fn_root_names << k
continue
}
Expand All @@ -325,11 +332,6 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
all_fn_root_names << k
continue
}
if k.ends_with('.lock') || k.ends_with('.unlock') || k.ends_with('.rlock')
|| k.ends_with('.runlock') {
all_fn_root_names << k
continue
}
if mfn.receiver.typ != ast.void_type && mfn.generic_names.len > 0 {
// generic methods may be used in cgen after specialisation :-|
// TODO: move generic method specialisation from cgen to before markused
Expand All @@ -338,11 +340,12 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
}
// testing framework:
if pref_.is_test {
if k.starts_with('test_') || k.contains('.test_') || k.contains('.vtest_') {
if k.starts_with('test_')
|| (has_dot && (k.contains('.test_') || k.contains('.vtest_'))) {
all_fn_root_names << k
continue
}
if k.starts_with('testsuite_') || k.contains('.testsuite_') {
if k.starts_with('testsuite_') || (has_dot && k.contains('.testsuite_')) {
all_fn_root_names << k
continue
}
Expand Down

0 comments on commit f2f0dfe

Please sign in to comment.