1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

Leverage buffer.Read

This commit is contained in:
v2ray 2016-07-17 12:18:26 +02:00
parent a39132f4c2
commit 089de290ad
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -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() {