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

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

This commit is contained in:
Alexander Medvednikov 2020-05-05 23:25:14 +02:00
parent 8fbbf488ab
commit 25b536d03f

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);')
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}')