diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-06-10 15:31:02 +0300 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-06-10 15:31:05 +0300 |
commit | ce9d1d2224df0b32cf58b6ce92e0c37b30007932 (patch) | |
tree | a37c8a0e99fbe1357cd6361c0c8536ef23b0997e /stream.go | |
parent | typo fix (diff) | |
download | fasthttp-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.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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() |