mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-18 02:16:10 -05:00
remove unused code
This commit is contained in:
parent
8868fe68ed
commit
e362c74fa9
@ -1,10 +1,6 @@
|
|||||||
package buf
|
package buf
|
||||||
|
|
||||||
import (
|
import "io"
|
||||||
"io"
|
|
||||||
|
|
||||||
"v2ray.com/core/common/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// BufferedWriter is an io.Writer with internal buffer. It writes to underlying writer when buffer is full or on demand.
|
// BufferedWriter is an io.Writer with internal buffer. It writes to underlying writer when buffer is full or on demand.
|
||||||
// This type is not thread safe.
|
// This type is not thread safe.
|
||||||
@ -23,25 +19,6 @@ func NewBufferedWriter(rawWriter io.Writer) *BufferedWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFrom implements io.ReaderFrom.ReadFrom().
|
|
||||||
func (v *BufferedWriter) ReadFrom(reader io.Reader) (int64, error) {
|
|
||||||
totalBytes := int64(0)
|
|
||||||
for {
|
|
||||||
oriSize := v.buffer.Len()
|
|
||||||
err := v.buffer.AppendSupplier(ReadFrom(reader))
|
|
||||||
totalBytes += int64(v.buffer.Len() - oriSize)
|
|
||||||
if err != nil {
|
|
||||||
if errors.Cause(err) == io.EOF {
|
|
||||||
return totalBytes, nil
|
|
||||||
}
|
|
||||||
return totalBytes, err
|
|
||||||
}
|
|
||||||
if err := v.Flush(); err != nil {
|
|
||||||
return totalBytes, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *BufferedWriter) Write(b []byte) (int, error) {
|
func (v *BufferedWriter) Write(b []byte) (int, error) {
|
||||||
if !v.buffered || v.buffer == nil {
|
if !v.buffered || v.buffer == nil {
|
||||||
return v.writer.Write(b)
|
return v.writer.Write(b)
|
||||||
|
Loading…
Reference in New Issue
Block a user