cgen: minor opitimize `infix_expr` (#5547)

pull/5548/head
yuyi 2020-06-28 17:35:49 +08:00 committed by GitHub
parent 13783aea70
commit b924c6c4a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -1828,11 +1828,10 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
g.expr(node.left)
g.write(')')
}
} else if node.op == .left_shift && g.table.get_type_symbol(left_type).kind == .array {
} else if node.op == .left_shift && left_sym.kind == .array {
// arr << val
tmp := g.new_tmp_var()
sym := g.table.get_type_symbol(left_type)
info := sym.info as table.Array
info := left_sym.info as table.Array
if right_sym.kind == .array && info.elem_type != node.right_type {
// push an array => PUSH_MANY, but not if pushing an array to 2d array (`[][]int << []int`)
g.write('_PUSH_MANY(&')