initial reduce pointer derefs and improve bce in templates

This commit is contained in:
Azareal 2020-03-03 23:02:46 +10:00
parent 9e6d33b39d
commit 24107aaef1
1 changed files with 5 additions and 3 deletions

View File

@ -657,9 +657,11 @@ func getTemplateList(c *tmpl.CTemplateSet, wg *sync.WaitGroup, prefix string) st
out := "package " + c.GetConfig().PackageName + "\n\n" out := "package " + c.GetConfig().PackageName + "\n\n"
getterstr := "\n// nolint\nGetFrag = func(name string) [][]byte {\nswitch(name) {\n" getterstr := "\n// nolint\nGetFrag = func(name string) [][]byte {\nswitch(name) {\n"
for templateName, count := range tFragCount { for templateName, count := range tFragCount {
out += "var " + templateName + "_frags = make([][]byte," + strconv.Itoa(count) + ")\n" //out += "var " + templateName + "_frags = make([][]byte," + strconv.Itoa(count) + ")\n"
out += "var " + templateName + "_frags [" + strconv.Itoa(count) + "][]byte\n"
getterstr += "\tcase \"" + templateName + "\":\n" getterstr += "\tcase \"" + templateName + "\":\n"
getterstr += "\treturn " + templateName + "_frags\n" //getterstr += "\treturn " + templateName + "_frags\n"
getterstr += "\treturn " + templateName + "_frags[:]\n"
} }
getterstr += "}\nreturn nil\n}\n" getterstr += "}\nreturn nil\n}\n"
out += pout + "\n" + getterstr + "}\n" out += pout + "\n" + getterstr + "}\n"