mirror of
https://github.com/vlang/v.git
synced 2025-09-18 03:46:36 -04:00
cgen,markused: skip struct none {
in cgen, if none
is not used by V code reachable from fn main() {
(#24824)
This commit is contained in:
parent
d05dc1f519
commit
2c063ea191
@ -40,6 +40,7 @@ pub mut:
|
||||
used_veb_types []Type // veb context types, filled in by checker
|
||||
used_maps int // how many times maps were used, filled in by markused
|
||||
used_arrays int // how many times arrays were used, filled in by markused
|
||||
used_none int // how many times `none` was used, filled in by markused
|
||||
external_types bool // true, when external type is used
|
||||
// json bool // json is imported
|
||||
debugger bool // debugger is used
|
||||
|
@ -6635,7 +6635,7 @@ fn (mut g Gen) write_types(symbols []&ast.TypeSymbol) {
|
||||
if sym.name.starts_with('C.') {
|
||||
continue
|
||||
}
|
||||
if sym.kind == .none {
|
||||
if sym.kind == .none && (!g.pref.skip_unused || g.table.used_features.used_none > 0) {
|
||||
g.type_definitions.writeln('struct none {')
|
||||
g.type_definitions.writeln('\tEMPTY_STRUCT_DECLARATION;')
|
||||
g.type_definitions.writeln('};')
|
||||
|
@ -540,6 +540,10 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
|
||||
}
|
||||
}
|
||||
|
||||
table.used_features.used_none = walker.used_none
|
||||
if walker.used_none == 0 {
|
||||
walker.used_fns.delete('${int(ast.none_type)}.str')
|
||||
}
|
||||
table.used_features.used_fns = walker.used_fns.move()
|
||||
table.used_features.used_consts = walker.used_consts.move()
|
||||
table.used_features.used_globals = walker.used_globals.move()
|
||||
|
Loading…
x
Reference in New Issue
Block a user