1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

View File

@ -3501,7 +3501,8 @@ fn (mut g Gen) match_expr(node ast.MatchExpr) {
g.inside_ternary++ g.inside_ternary++
// g.write('/* EM ret type=${g.typ(node.return_type)} expected_type=${g.typ(node.expected_type)} */') // 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 pos := g.out.len
g.expr(node.cond) g.expr(node.cond)
cond_var = g.out.after(pos) cond_var = g.out.after(pos)