Skip to content

Commit

Permalink
cgen: reduce indentation level for generated defer statements
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Aug 7, 2024
1 parent 2d86c34 commit 74e40c5
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -2375,27 +2375,23 @@ fn (mut g Gen) stmt(node ast.Stmt) {
}

fn (mut g Gen) write_defer_stmts() {
g.indent++
for i := g.defer_stmts.len - 1; i >= 0; i-- {
defer_stmt := g.defer_stmts[i]
g.writeln('// Defer begin')
g.writeln('if (${g.defer_flag_var(defer_stmt)}) {')
g.indent++
// g.indent++
if defer_stmt.ifdef.len > 0 {
g.writeln(defer_stmt.ifdef)
g.stmts(defer_stmt.stmts)
g.writeln('')
g.writeln('#endif')
} else {
g.indent--
g.stmts(defer_stmt.stmts)
g.indent++
}
g.indent--
// g.indent--
g.writeln('}')
g.writeln('// Defer end')
}
g.indent--
}

struct SumtypeCastingFn {
Expand Down

0 comments on commit 74e40c5

Please sign in to comment.