From f903ef24e8bed34f247da0236a74994161384a44 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 18 Mar 2022 14:50:30 +0000 Subject: [PATCH] cgen: simplify slicing fixed array (#13767) --- vlib/v/gen/c/index.v | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/vlib/v/gen/c/index.v b/vlib/v/gen/c/index.v index 8ff1dd7633..24540b51a8 100644 --- a/vlib/v/gen/c/index.v +++ b/vlib/v/gen/c/index.v @@ -115,17 +115,8 @@ fn (mut g Gen) range_expr(node ast.IndexExpr, range ast.RangeExpr) { g.write('array_slice(') } g.write('new_array_from_c_array${noscan}(') - g.write('$info.size') - g.write(', $info.size') - g.write(', sizeof(') - if node.left_type.is_ptr() { - g.write('(*') - } - g.expr(node.left) - if node.left_type.is_ptr() { - g.write(')') - } - g.write('[0]), ') + ctype := g.typ(info.elem_type) + g.write('$info.size, $info.size, sizeof($ctype), ') if node.left_type.is_ptr() { g.write('*') }