use normal byte array

pull/642/head
Darien Raymond 8 years ago
parent a7abac2eaf
commit 5a30e27f04
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -83,7 +83,7 @@ func NewReader(reader io.Reader) Reader {
return &BytesToBufferReader{
reader: reader,
buffer: NewLocal(32 * 1024),
buffer: make([]byte, 32*1024),
}
}

@ -9,20 +9,23 @@ import (
// BytesToBufferReader is a Reader that adjusts its reading speed automatically.
type BytesToBufferReader struct {
reader io.Reader
buffer *Buffer
buffer []byte
}
// Read implements Reader.Read().
func (r *BytesToBufferReader) Read() (MultiBuffer, error) {
if err := r.buffer.Reset(ReadFrom(r.reader)); err != nil {
nBytes, err := r.reader.Read(r.buffer)
if err != nil {
return nil, err
}
mb := NewMultiBuffer()
for !r.buffer.IsEmpty() {
p := r.buffer[:nBytes]
for len(p) > 0 {
b := New()
b.AppendSupplier(ReadFrom(r.buffer))
nBytes, _ := b.Write(p)
mb.Append(b)
p = p[nBytes:]
}
return mb, nil
}

Loading…
Cancel
Save