loop only on readers once

This commit is contained in:
Harshavardhana 2015-03-25 14:48:46 -07:00
parent d9bd5e2e10
commit c366fdd2d8

View File

@ -67,9 +67,6 @@ func erasureReader(readers []io.ReadCloser, donutMetadata map[string]string, wri
summer := md5.New()
params, _ := erasure.ParseEncoderParams(uint8(k), uint8(m), technique)
encoder := erasure.NewEncoder(params)
for _, reader := range readers {
defer reader.Close()
}
for i := 0; i < totalChunks; i++ {
curBlockSize := totalLeft
if blockSize < totalLeft {
@ -80,6 +77,7 @@ func erasureReader(readers []io.ReadCloser, donutMetadata map[string]string, wri
encodedBytes := make([][]byte, 16)
for i, reader := range readers {
defer reader.Close()
var bytesBuffer bytes.Buffer
_, err := io.CopyN(&bytesBuffer, reader, int64(curChunkSize))
if err != nil {