From 6288e760a9567d840f071a69ee3f768bc966a33d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 8 Mar 2023 15:19:09 +0000 Subject: [PATCH] Reuse `buf` (though `io.CopyBuffer()` is not likely to actually use it) --- tls.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tls.go b/tls.go index d142d29..a45267e 100644 --- a/tls.go +++ b/tls.go @@ -265,7 +265,7 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) { } else { copying = true mutex.Unlock() - io.Copy(target, underlying) + io.CopyBuffer(target, underlying, buf) } waitGroup.Done() }() @@ -330,7 +330,7 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) { } if i == 2 && handshakeLen > 512 { hs.c.out.handshakeLen[i] = handshakeLen - hs.c.out.handshakeBuf = s2cSaved[:0] + hs.c.out.handshakeBuf = buf[:0] break } if i == 6 && handshakeLen > 0 { @@ -368,7 +368,7 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) { } else { copying = true mutex.Unlock() - io.Copy(underlying, target) + io.CopyBuffer(underlying, target, buf) } waitGroup.Done() }()