From e8abda189aeb5e0667c15d77d03f64dabe0fac43 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sat, 20 Feb 2021 21:51:40 +0800 Subject: [PATCH] cgen: minor optimization in match_expr() (#8848) --- vlib/v/gen/c/cgen.v | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 256d862aa7..ca10468a1f 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3501,7 +3501,8 @@ fn (mut g Gen) match_expr(node ast.MatchExpr) { g.inside_ternary++ // g.write('/* EM ret type=${g.typ(node.return_type)} expected_type=${g.typ(node.expected_type)} */') } - if node.cond is ast.Ident || node.cond is ast.SelectExpr || node.cond is ast.IndexExpr { + if node.cond is ast.Ident || node.cond is ast.SelectorExpr || node.cond is ast.IntegerLiteral + || node.cond is ast.StringLiteral || node.cond is ast.FloatLiteral { pos := g.out.len g.expr(node.cond) cond_var = g.out.after(pos)