From 9cc9a76b71669dec1e8fcdbef9cc31c9acd14ce0 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 8 Nov 2017 11:11:13 +0100 Subject: [PATCH] cleanup --- common/crypto/chunk.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/crypto/chunk.go b/common/crypto/chunk.go index b3368c10..0fc89db8 100644 --- a/common/crypto/chunk.go +++ b/common/crypto/chunk.go @@ -8,11 +8,13 @@ import ( "v2ray.com/core/common/serial" ) +// ChunkSizeDecoder is an utility class to decode size value from bytes. type ChunkSizeDecoder interface { SizeBytes() int Decode([]byte) (uint16, error) } +// ChunkSizeEncoder is an utility class to encode size value into bytes. type ChunkSizeEncoder interface { SizeBytes() int Encode(uint16, []byte) []byte @@ -134,7 +136,7 @@ func (w *ChunkStreamWriter) Write(mb buf.MultiBuffer) error { slice := mb.SliceBySize(sliceSize) b := buf.New() - common.Must(b.AppendSupplier(func(buffer []byte) (int, error) { + common.Must(b.Reset(func(buffer []byte) (int, error) { w.sizeEncoder.Encode(uint16(slice.Len()), buffer[:0]) return w.sizeEncoder.SizeBytes(), nil }))