From 7daf8f8fd0c9a0d06803902327f64e013c747a99 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Wed, 4 Mar 2020 22:39:18 +1100 Subject: [PATCH] v2: simplify MatchExpr in vfmt --- vlib/v/fmt/fmt.v | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index d07b7b45bd..5c5a9bf7da 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -443,19 +443,17 @@ fn (f mut Fmt) expr(node ast.Expr) { f.write(', ') } } - f.writeln(' {') - f.stmts(branch.stmts) - f.writeln('}') } // else branch else { - if (branch.stmts.len == 0) { - f.writeln('else {}') - } else { - f.writeln('else {') - f.stmts(branch.stmts) - f.writeln('}') - } + f.write('else') + } + if (branch.stmts.len == 0) { + f.writeln(' {}') + } else { + f.writeln(' {') + f.stmts(branch.stmts) + f.writeln('}') } } f.indent--