mount: shortcut when there is only one chunk

This commit is contained in:
Chris Lu
2020-10-20 23:48:29 -07:00
parent f64252023e
commit c31b254248
3 changed files with 28 additions and 5 deletions

View File

@@ -3,6 +3,8 @@ package filesys
import (
"bytes"
"io"
"github.com/chrislusf/seaweedfs/weed/util"
)
type IntervalNode struct {
@@ -200,10 +202,13 @@ func (c *ContinuousIntervals) ReadDataAt(data []byte, startOffset int64) (maxSto
func (l *IntervalLinkedList) ToReader() io.Reader {
var readers []io.Reader
t := l.Head
readers = append(readers, bytes.NewReader(t.Data))
readers = append(readers, util.NewBytesReader(t.Data))
for t.Next != nil {
t = t.Next
readers = append(readers, bytes.NewReader(t.Data))
}
if len(readers) == 1 {
return readers[0]
}
return io.MultiReader(readers...)
}