From 2c52228fae92675f20d8b0f77fd23cd5cdc133ae Mon Sep 17 00:00:00 2001 From: Lee McDermott Date: Wed, 24 Nov 2021 19:06:36 +0000 Subject: [PATCH] Just use the incoming buffer if we're at zero, rather than copying --- Sources/NIOHTTP2/HTTP2FrameParser.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/NIOHTTP2/HTTP2FrameParser.swift b/Sources/NIOHTTP2/HTTP2FrameParser.swift index 2b00aa39..23e93b0a 100644 --- a/Sources/NIOHTTP2/HTTP2FrameParser.swift +++ b/Sources/NIOHTTP2/HTTP2FrameParser.swift @@ -64,7 +64,12 @@ struct HTTP2FrameDecoder { } mutating func accumulate(bytes: inout ByteBuffer) { - _ = self.unusedBytes.writeBuffer(&bytes) + if self.unusedBytes.readableBytes == 0 { + self.unusedBytes = bytes + } + else { + _ = self.unusedBytes.writeBuffer(&bytes) + } } }