diff options
author | Mike Faraponov <11322032+moredure@users.noreply.github.com> | 2021-02-24 21:43:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 20:43:56 +0100 |
commit | 0880335533c13d3c0fee91f749a5a31b3ed185b0 (patch) | |
tree | bff95a6772a2509142f2be49469bca7d62639bcc /compress.go | |
parent | Update client.go (#979) (diff) | |
download | fasthttp-0880335533c13d3c0fee91f749a5a31b3ed185b0.tar.gz fasthttp-0880335533c13d3c0fee91f749a5a31b3ed185b0.tar.bz2 fasthttp-0880335533c13d3c0fee91f749a5a31b3ed185b0.zip |
Update compress.go (#978)
Add compatibility with flate.Reader to reduce allocations of bufio.NewReader structs backed by default size slices.
Diffstat (limited to 'compress.go')
-rw-r--r-- | compress.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compress.go b/compress.go index 6550c9e..f590d28 100644 --- a/compress.go +++ b/compress.go @@ -342,6 +342,15 @@ func (r *byteSliceReader) Read(p []byte) (int, error) { return n, nil } +func (r *byteSliceReader) ReadByte() (byte, error) { + if len(r.b) == 0 { + return 0, io.EOF + } + n := r.b[0] + r.b = r.b[1:] + return n, nil +} + func acquireStacklessDeflateWriter(w io.Writer, level int) stackless.Writer { nLevel := normalizeCompressLevel(level) p := stacklessDeflateWriterPoolMap[nLevel] |