func (tsd *Digest) copyWithBuf(dst io.Writer, src io.Reader) (written int64, err error) {
	if tsd.copyBuf == nil {
		tsd.copyBuf = make([]byte, 32*1024)
	}

	for {
		nr, er := src.Read(tsd.copyBuf)
		if nr > 0 {
			nw, ew := dst.Write(tsd.copyBuf[0:nr])
			if nw > 0 {
				written += int64(nw)
			}
			if ew != nil {
				err = ew
				break
			}
			if nr != nw {
				err = io.ErrShortWrite
				break
			}
		}
		if er == io.EOF {
			break
		}
		if er != nil {
			err = er
			break
		}
	}
	return
}
// Like `io.Copy` except it only ever does one allocation of the 32K buffer.
Like `io.Copy` except it only ever does one allocation of the 32K buffer.
// Like ` io . Copy ` except it only ever does one allocation of the 32K buffer .
func (tsd *Digest) copyWithBuf(dst io.Writer, src io.Reader) (written int64, err error) {
	if tsd.copyBuf == nil {
		tsd.copyBuf = make([]byte, 32*1024)
	}
	for {
		nr, er := src.Read(tsd.copyBuf)
		if nr > 0 {
			nw, ew := dst.Write(tsd.copyBuf[0:nr])
			if nw > 0 {
				written += int64(nw)
			}
			if ew != nil {
				err = ew
				break
			}
			if nr != nw {
				err = io.ErrShortWrite
				break
			}
		}
		if er == io.EOF {
			break
		}
		if er != nil {
			err = er
			break
		}
	}
	return
}
func ( tsd * Digest ) copyWithBuf ( dst io . Writer , src io . Reader ) ( written int64 , err error ) { if tsd . copyBuf == nil { tsd . copyBuf = make ( [ ] byte , 32 * 1024 ) } for { nr , er := src . Read ( tsd . copyBuf ) if nr > 0 { nw , ew := dst . Write ( tsd . copyBuf [ 0 : nr ] ) if nw > 0 { written += int64 ( nw ) } if ew != nil { err = ew break } if nr != nw { err = io . ErrShortWrite break } } if er == io . EOF { break } if er != nil { err = er break } } return }
Like `io.Copy` except it only ever does one allocation of the 32K buffer.
Like ` io . Copy ` except it only ever does one allocation of the 32K buffer .