cgen: minor optimization in match_expr() (#8848)

pull/8859/head
yuyi 2021-02-20 21:51:40 +08:00 committed by GitHub
parent 2be852e461
commit e8abda189a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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)