Skip to content

Commit

Permalink
Update compress.go (#978)
Browse files Browse the repository at this point in the history
Add compatibility with flate.Reader to reduce allocations of bufio.NewReader structs backed by default size slices.
  • Loading branch information
moredure committed Feb 24, 2021
1 parent e7294d2 commit 0880335
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 0880335

Please sign in to comment.