From 6ac7d2caee89cdfdb4f6c273a88d1173d234c21b Mon Sep 17 00:00:00 2001 From: dchapes Date: Sat, 11 Feb 2017 14:45:20 -0500 Subject: Accept interfaces where appropriate. (#103) * Accept interfaces where appropriate. `Fpdf.RawWriteBuf` only needs an `io.Reader`, it doesn't have to be a `bytes.Buffer`. The only reason I can see not to do this is to avoid the interface "boxing" if the caller is actually using a `bytes.Buffer`; however, since eventually this gets into `binary.Read` which takes an `io.Reader` the boxing will happen anyway (and possibly repeatedly if `readByte` gets called a number of times; I didn't bother to check). * Also use interface for segmentRead * Use read-only bytes.Reader instead of bytes.Buffer where appropriate. --- util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util.go') diff --git a/util.go b/util.go index 149271c..2c8c5bb 100644 --- a/util.go +++ b/util.go @@ -93,7 +93,7 @@ func sliceCompress(data []byte) []byte { // Returns an uncompressed copy of the specified zlib-compressed byte array func sliceUncompress(data []byte) (outData []byte, err error) { - inBuf := bytes.NewBuffer(data) + inBuf := bytes.NewReader(data) r, err := zlib.NewReader(inBuf) defer r.Close() if err == nil { -- cgit v1.2.1-24-ge1ad