func (v *View) WriteFromReader(r io.Reader, count int64) (int64, error) {
	var (
		done int64
		n    int
		err  error
	)
	for done < count {
		buf := v.data.Back()

		// Find the first empty buffer.
		if buf == nil || buf.Full() {
			buf = bufferPool.Get().(*Buffer)
			v.data.PushBack(buf)
		}

		// Is this less than the minimum batch?
		if len(buf.data[buf.write:]) < minBatch && (count-done) >= int64(minBatch) {
			tmp := make([]byte, minBatch)
			n, err = r.Read(tmp)
			v.Write(tmp[:n])
			done += int64(n)
			if err != nil {
				break
			}
			continue
		}

		// Limit the read, if necessary.
		end := len(buf.data)
		if int64(end-buf.write) > (count - done) {
			end = buf.write + int(count-done)
		}

		// Pass the relevant portion of the buffer.
		n, err = r.Read(buf.data[buf.write:end])
		buf.write += n
		done += int64(n)
		v.size += int64(n)
		if err == io.EOF {
			err = nil // Short write allowed.
			break
		} else if err != nil {
			break
		}
	}
	return done, err
}
// WriteFromReader writes to the buffer from an io.Reader.
WriteFromReader writes to the buffer from an io.Reader.
// WriteFromReader writes to the buffer from an io . Reader .
func (v *View) WriteFromReader(r io.Reader, count int64) (int64, error) {
	var (
		done int64
		n    int
		err  error
	)
	for done < count {
		buf := v.data.Back()
		if buf == nil || buf.Full() {
			buf = bufferPool.Get().(*Buffer)
			v.data.PushBack(buf)
		}
		if len(buf.data[buf.write:]) < minBatch && (count-done) >= int64(minBatch) {
			tmp := make([]byte, minBatch)
			n, err = r.Read(tmp)
			v.Write(tmp[:n])
			done += int64(n)
			if err != nil {
				break
			}
			continue
		}
		end := len(buf.data)
		if int64(end-buf.write) > (count - done) {
			end = buf.write + int(count-done)
		}
		n, err = r.Read(buf.data[buf.write:end])
		buf.write += n
		done += int64(n)
		v.size += int64(n)
		if err == io.EOF {
			err = nil 
			break
		} else if err != nil {
			break
		}
	}
	return done, err
}
func ( v * View ) WriteFromReader ( r io . Reader , count int64 ) ( int64 , error ) { var ( done int64 n int err error ) for done < count { buf := v . data . Back ( ) if buf == nil || buf . Full ( ) { buf = bufferPool . Get ( ) . ( * Buffer ) v . data . PushBack ( buf ) } if len ( buf . data [ buf . write : ] ) < minBatch && ( count - done ) >= int64 ( minBatch ) { tmp := make ( [ ] byte , minBatch ) n , err = r . Read ( tmp ) v . Write ( tmp [ : n ] ) done += int64 ( n ) if err != nil { break } continue } end := len ( buf . data ) if int64 ( end - buf . write ) > ( count - done ) { end = buf . write + int ( count - done ) } n , err = r . Read ( buf . data [ buf . write : end ] ) buf . write += n done += int64 ( n ) v . size += int64 ( n ) if err == io . EOF { err = nil break } else if err != nil { break } } return done , err }
WriteFromReader writes to the buffer from an io.Reader.
WriteFromReader writes to the buffer from an io . Reader .
// Find the first empty buffer. // Is this less than the minimum batch? // Limit the read, if necessary. // Pass the relevant portion of the buffer. // Short write allowed.