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

cgen: minor opitimize infix_expr (#5547)

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

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(&')