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

compiler: simplify [0; n]

This commit is contained in:
Alexander Medvednikov 2019-08-31 01:30:28 +03:00
parent 04a200d3d8
commit 29b4114bc0
2 changed files with 1 additions and 11 deletions

View File

@ -115,7 +115,6 @@ typedef map map_string;
//#define ALLOC_INIT(type, ...) (type *)memdup((type[]){ __VA_ARGS__ }, sizeof(type))
//================================== GLOBALS =================================*/
//int V_ZERO = 0;
byteptr g_str_buf;
int load_so(byteptr);
void reload_so();

View File

@ -2686,17 +2686,8 @@ fn (p mut Parser) array_init() string {
if i == 1 && p.tok == .semicolon {
p.check_space(.semicolon)
val := p.cgen.cur_line.right(pos)
// p.cgen.cur_line = ''
p.cgen.resetln(p.cgen.cur_line.left(pos))
// Special case for zero
if false && val.trim_space() == '0' {
p.gen('array_repeat( & V_ZERO, ')
}
else {
tmp := p.get_tmp()
p.cgen.insert_before('$typ $tmp = $val;')
p.gen('array_repeat(&$tmp, ')
}
p.gen('array_repeat(& ($typ[]){ $val }, ')
p.check_types(p.bool_expression(), 'int')
p.gen(', sizeof($typ) )')
p.check(.rsbr)