cgen: str: do not free "true"/"false" literals

pull/4743/head
Alexander Medvednikov 2020-05-05 23:25:14 +02:00
parent 8fbbf488ab
commit 25b536d03f
1 changed files with 4 additions and 1 deletions

View File

@ -3310,7 +3310,10 @@ fn (mut g Gen) gen_str_for_array(info table.Array, styp, str_fn_name string) {
g.auto_str_funcs.writeln('\t\tstring x = ${field_styp}_str(it);')
}
g.auto_str_funcs.writeln('\t\tstrings__Builder_write(&sb, x);')
g.auto_str_funcs.writeln('\t\tstring_free(x);')
if info.elem_type != table.bool_type {
// no need to free "true"/"false" literals
g.auto_str_funcs.writeln('\t\tstring_free(x);')
}
g.auto_str_funcs.writeln('\t\tif (i < a.len-1) {')
g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write(&sb, tos3(", "));')
g.auto_str_funcs.writeln('\t\t}')