cgen: minor cleanup (use replace_each) (#6978)

pull/6980/head
Swastik Baranwal 2020-11-27 20:43:30 +05:30 committed by GitHub
parent bbea7fb91f
commit 2473f65278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -509,8 +509,7 @@ fn (g &Gen) cc_type2(t table.Type) string {
}
styp += sgtyps
} else if styp.contains('<') {
// TODO: yuck
styp = styp.replace('<', '_T_').replace('>', '').replace(',', '_')
styp = styp.replace_each(['<', '_T_', '>', '', ',', '_'])
}
}
return styp
@ -4512,9 +4511,8 @@ fn (mut g Gen) write_types(types []table.TypeSymbol) {
if typ.info.generic_types.len > 0 {
continue
}
// TODO: yuck
if name.contains('<') {
name = name.replace('<', '_T_').replace('>', '').replace(',', '_')
name = name.replace_each(['<', '_T_', '>', '', ',', '_'])
g.typedefs.writeln('typedef struct $name $name;')
}
// TODO avoid buffer manip