aboutsummaryrefslogtreecommitdiff
path: root/stream.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-06-10 15:31:02 +0300
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-06-10 15:31:05 +0300
commitce9d1d2224df0b32cf58b6ce92e0c37b30007932 (patch)
treea37c8a0e99fbe1357cd6361c0c8536ef23b0997e /stream.go
parenttypo fix (diff)
downloadfasthttp-ce9d1d2224df0b32cf58b6ce92e0c37b30007932.tar.gz
fasthttp-ce9d1d2224df0b32cf58b6ce92e0c37b30007932.tar.bz2
fasthttp-ce9d1d2224df0b32cf58b6ce92e0c37b30007932.zip
Use fasthttp.PipeConns instead of io.Pipe in StreamReader
This improves StreamReader performance by more than 2x.
Diffstat (limited to 'stream.go')
-rw-r--r--stream.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/stream.go b/stream.go
index 349bd5b..24bd553 100644
--- a/stream.go
+++ b/stream.go
@@ -5,6 +5,8 @@ import (
"io"
"runtime/debug"
"sync"
+
+ "github.com/valyala/fasthttp/fasthttputil"
)
// StreamWriter must write data to w.
@@ -26,7 +28,9 @@ type StreamWriter func(w *bufio.Writer)
//
// See also Response.SetBodyStreamWriter.
func NewStreamReader(sw StreamWriter) io.ReadCloser {
- pr, pw := io.Pipe()
+ pc := fasthttputil.NewPipeConns()
+ pw := pc.Conn1()
+ pr := pc.Conn2()
var bw *bufio.Writer
v := streamWriterBufPool.Get()