From 089de290ad4555f37211fae9665e62d0a28d1959 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sun, 17 Jul 2016 12:18:26 +0200 Subject: [PATCH] Leverage buffer.Read --- common/io/chan_reader.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/common/io/chan_reader.go b/common/io/chan_reader.go index 89ed1aa93..e1fbdb93b 100644 --- a/common/io/chan_reader.go +++ b/common/io/chan_reader.go @@ -45,14 +45,12 @@ func (this *ChanReader) Read(b []byte) (int, error) { return 0, io.EOF } } - nBytes := copy(b, this.current.Value) - if nBytes == this.current.Len() { + nBytes, err := this.current.Read(b) + if this.current.IsEmpty() { this.current.Release() this.current = nil - } else { - this.current.SliceFrom(nBytes) } - return nBytes, nil + return nBytes, err } func (this *ChanReader) Release() {