mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 07:26:24 -05:00
Revert change a766c61dcc
as it actually downgrade performance. Will investigate later.
This commit is contained in:
parent
7d92b6a4fb
commit
7d73ef1150
@ -31,7 +31,8 @@ func putBuffer(buffer []byte) {
|
|||||||
|
|
||||||
func ReaderToChan(stream chan<- []byte, reader io.Reader) error {
|
func ReaderToChan(stream chan<- []byte, reader io.Reader) error {
|
||||||
for {
|
for {
|
||||||
buffer := getBuffer()
|
buffer := make([]byte, bufferSize)
|
||||||
|
//buffer := getBuffer()
|
||||||
nBytes, err := reader.Read(buffer)
|
nBytes, err := reader.Read(buffer)
|
||||||
if nBytes > 0 {
|
if nBytes > 0 {
|
||||||
stream <- buffer[:nBytes]
|
stream <- buffer[:nBytes]
|
||||||
@ -46,7 +47,7 @@ func ReaderToChan(stream chan<- []byte, reader io.Reader) error {
|
|||||||
func ChanToWriter(writer io.Writer, stream <-chan []byte) error {
|
func ChanToWriter(writer io.Writer, stream <-chan []byte) error {
|
||||||
for buffer := range stream {
|
for buffer := range stream {
|
||||||
_, err := writer.Write(buffer)
|
_, err := writer.Write(buffer)
|
||||||
putBuffer(buffer)
|
//putBuffer(buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user