Make decryptReader fulfill flate.Reader

benchmark               old ns/op     new ns/op     delta
    BenchmarkLoadJSONID     50232171      48596972      -3.26%

    benchmark               old allocs     new allocs     delta
    BenchmarkLoadJSONID     43643          42884          -1.74%

    benchmark               old bytes     new bytes     delta
    BenchmarkLoadJSONID     5773048       3785517       -34.43%
This commit is contained in:
Alexander Neumann 2015-02-18 23:30:59 +01:00
parent a0fea201d9
commit 2f3aa344af
2 changed files with 22 additions and 1 deletions

18
key.go
View file

@ -543,6 +543,24 @@ func (d *decryptReader) Read(dst []byte) (int, error) {
return n, nil
}
func (d *decryptReader) ReadByte() (c byte, err error) {
if d.buf == nil {
return 0, io.EOF
}
remaining := len(d.buf) - d.pos
if remaining == 1 {
c = d.buf[d.pos]
d.Close()
return c, io.EOF
}
c = d.buf[d.pos]
d.pos++
return
}
func (d *decryptReader) Close() error {
if d.buf == nil {
return nil