From 35129e6518aaaac8dae8dfcffa440b12efcbb15a Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Thu, 9 Aug 2018 13:30:44 +0200 Subject: [PATCH] allocate copyHandler on stack --- common/buf/copy.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/buf/copy.go b/common/buf/copy.go index e6118179..bc0a8d1f 100644 --- a/common/buf/copy.go +++ b/common/buf/copy.go @@ -103,11 +103,11 @@ func copyInternal(reader Reader, writer Writer, handler *copyHandler) error { // Copy dumps all payload from reader to writer or stops when an error occurs. It returns nil when EOF. func Copy(reader Reader, writer Writer, options ...CopyOption) error { - handler := new(copyHandler) + var handler copyHandler for _, option := range options { - option(handler) + option(&handler) } - err := copyInternal(reader, writer, handler) + err := copyInternal(reader, writer, &handler) if err != nil && errors.Cause(err) != io.EOF { return err }