Skip to content

Commit

Permalink
Merge pull request #1 from skit-ai/mem-perf
Browse files Browse the repository at this point in the history
update: use io.Copy instead of io.ReadAll in NewDecoder
  • Loading branch information
sreeram-narayanan authored Jan 23, 2024
2 parents 966cb87 + eedd319 commit 044fd4f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wav/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ type Decoder struct {
}

func NewDecoder(r io.Reader) (*Decoder, error) {
buf, err := io.ReadAll(r)
buf := &bytes.Buffer{}

_, err := io.Copy(buf, r)
if err != nil {
return nil, err
}

d := &Decoder{buffer: buf}
d := &Decoder{buffer: buf.Bytes()}
d.chunks = d.readChunks()

return d, nil
Expand Down

0 comments on commit 044fd4f

Please sign in to comment.