mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Don't zero buffer if big enough (#13877)
Only append zeroed bytes when we don't have enough space anyway.
This commit is contained in:
parent
a02e17f15c
commit
81e43b87c2
@ -658,7 +658,12 @@ func readXLMetaNoData(r io.Reader, size int64) ([]byte, error) {
|
|||||||
return io.ErrUnexpectedEOF
|
return io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
extra := n - has
|
extra := n - has
|
||||||
|
if int64(cap(buf)) >= n {
|
||||||
|
// Extend since we have enough space.
|
||||||
|
buf = buf[:n]
|
||||||
|
} else {
|
||||||
buf = append(buf, make([]byte, extra)...)
|
buf = append(buf, make([]byte, extra)...)
|
||||||
|
}
|
||||||
_, err := io.ReadFull(r, buf[has:])
|
_, err := io.ReadFull(r, buf[has:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) {
|
||||||
|
Loading…
Reference in New Issue
Block a user