mirror of https://github.com/v2ray/v2ray-core
Leverage buffer.Read
parent
a39132f4c2
commit
089de290ad
|
@ -45,14 +45,12 @@ func (this *ChanReader) Read(b []byte) (int, error) {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nBytes := copy(b, this.current.Value)
|
nBytes, err := this.current.Read(b)
|
||||||
if nBytes == this.current.Len() {
|
if this.current.IsEmpty() {
|
||||||
this.current.Release()
|
this.current.Release()
|
||||||
this.current = nil
|
this.current = nil
|
||||||
} else {
|
|
||||||
this.current.SliceFrom(nBytes)
|
|
||||||
}
|
}
|
||||||
return nBytes, nil
|
return nBytes, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ChanReader) Release() {
|
func (this *ChanReader) Release() {
|
||||||
|
|
Loading…
Reference in New Issue