Skip to content

Commit

Permalink
Optimize byte slice copies
Browse files Browse the repository at this point in the history
  • Loading branch information
AWoloszyn committed May 25, 2018
1 parent 4392580 commit 9763afa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gapis/api/templates/api.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 9763afa

Please sign in to comment.