audio/internal/convert: Avoid unnecessary allocations

This commit is contained in:
Hajime Hoshi 2021-01-25 03:04:53 +09:00
parent 569964d7e4
commit c8ba51d26e

View File

@ -61,7 +61,9 @@ func (f *f32Reader) Read(buf []byte) (int, error) {
for ll < l {
ll *= 2
}
f.fbuf = make([]float32, ll)
if len(f.fbuf) < ll {
f.fbuf = make([]float32, ll)
}
n, err := f.r.Read(f.fbuf[:l])
if err != nil && err != io.EOF {