From 9763afa02801848c421e0059352bd4ff26b7910e Mon Sep 17 00:00:00 2001 From: Andrew Woloszyn Date: Fri, 25 May 2018 10:19:14 -0400 Subject: [PATCH] Optimize byte slice copies --- gapis/api/templates/api.go.tmpl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gapis/api/templates/api.go.tmpl b/gapis/api/templates/api.go.tmpl index 681fc631f8..5b5a4c9427 100644 --- a/gapis/api/templates/api.go.tmpl +++ b/gapis/api/templates/api.go.tmpl @@ -628,11 +628,15 @@ import ( func (s {{$slice_ty}}) Read(ϟctx context.Context, ϟc ϟapi.Cmd, ϟg *ϟapi.GlobalState, ϟb *builder.Builder) ([]{{$el_ty}}, error) { ϟa := ϟg.Arena; _ = ϟa s.OnRead(ϟctx, ϟc, ϟg, ϟb) - ϟd := s.Decoder(ϟctx, ϟg) out := make([]{{$el_ty}}, s.count) - for i := range out { - out[i] = {{Template "Go.Decode" $s.To}} - } + ϟd := s.Decoder(ϟctx, ϟg) + {{if IsU8 $s.To}} + ϟd.Data(out) + {{else}} + for i := range out { + out[i] = {{Template "Go.Decode" $s.To}} + } + {{end}} if err := ϟd.Error(); err != nil { return nil, err }