From 87d8f4575c3586e11e8211c21ae8f1b34886c7d9 Mon Sep 17 00:00:00 2001 From: Mike Faraponov <11322032+moredure@users.noreply.github.com> Date: Mon, 1 Mar 2021 19:42:42 +0200 Subject: [PATCH] Reduce allocations of buffer for reused readers --- reader.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reader.go b/reader.go index 5c795e6..280c4ff 100644 --- a/reader.go +++ b/reader.go @@ -33,6 +33,9 @@ func NewReader(src io.Reader) *Reader { func (r *Reader) Reset(src io.Reader) error { decoderStateInit(r) r.src = src + if r.buf != nil { + return nil + } r.buf = make([]byte, readBufSize) return nil }