From 820fe626e7c5e2e18c01ff019306c999ea6d7613 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 9 Apr 2021 17:56:36 +0300 Subject: [PATCH] v.gen.c: reduce slightly the generated C lines with -skip-unused (3940 -> 3699 for hello_world.v) --- vlib/v/gen/c/cgen.v | 7 ++++++- vlib/v/gen/c/fn.v | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index d2f0d0b666..9019b30096 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -1264,7 +1264,9 @@ fn (mut g Gen) stmt(node ast.Stmt) { } } ast.TypeDecl { - g.writeln('// TypeDecl') + if !g.pref.skip_unused { + g.writeln('// TypeDecl') + } } } if !g.skip_stmt_pos { // && g.stmt_path_pos.len > 0 { @@ -1793,6 +1795,9 @@ fn ctoslit(s string) string { } fn (mut g Gen) gen_attrs(attrs []ast.Attr) { + if g.pref.skip_unused { + return + } for attr in attrs { g.writeln('// Attr: [$attr.name]') } diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index 5943db143e..b2c612d6ea 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -86,8 +86,10 @@ fn (mut g Gen) process_fn_decl(node ast.FnDecl) { if skip { g.out.go_back_to(pos) } - if node.language != .c { - g.writeln('') + if !g.pref.skip_unused { + if node.language != .c { + g.writeln('') + } } }