Return []byte from encode, use it instead of bytes.Buffer

We only use Buffer for its internal buffer returned by Bytes() outside
encode() anyway, so there's no reason to hold on to whole Buffer object.
This commit is contained in:
Yuriy Taraday
2018-02-05 02:35:27 +04:00
parent 101d836616
commit 38a1eeb6c3
5 changed files with 793 additions and 793 deletions

View File

@@ -129,7 +129,7 @@ func decodeTypedParams(dec *xdr.Decoder) ([]TypedParam, error) {
{{range .Procs}}
// {{.Name}} is the go wrapper for {{.LVName}}.
func (l *Libvirt) {{.Name}}({{range $ix, $arg := .Args}}{{if $ix}}, {{end}}{{.Name}} {{.Type}}{{end}}) ({{range .Ret}}r{{.Name}} {{.Type}}, {{end}}err error) {
var buf bytes.Buffer
var buf []byte
{{if .ArgsStruct}}
args := {{.ArgsStruct}} {
{{range .Args}} {{.Name}}: {{.Name}},
@@ -141,7 +141,7 @@ func (l *Libvirt) {{.Name}}({{range $ix, $arg := .Args}}{{if $ix}}, {{end}}{{.Na
}
{{end}}
{{if .RetStruct}} var r response{{end}}
{{if .RetStruct}}r{{else}}_{{end}}, err = l.request({{.Num}}, constants.Program, &buf)
{{if .RetStruct}}r{{else}}_{{end}}, err = l.request({{.Num}}, constants.Program, buf)
if err != nil {
return
}