From 1b1de0ebeb89059db28ed554bdf251db9e26a4075ccb31352824beb3ff131b5f Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 15 Feb 2025 11:42:57 +0300 Subject: [PATCH] Tiny optimisation --- go/blob.go | 4 ++++ go/cm/enc/chapoly/dem.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/go/blob.go b/go/blob.go index 8f1c71c..ee45abb 100644 --- a/go/blob.go +++ b/go/blob.go @@ -82,6 +82,10 @@ func NewBlobDecoder(r io.Reader, maxChunkLen int64) (*BlobDecoder, error) { return &BlobDecoder{d: d, ChunkLen: chunkLen}, nil } +func (d *BlobDecoder) SetReadBuf(buf []byte) { + d.d.readBuf = buf +} + // Get the next chunk of the BLOB. Last one may be smaller size than the // ChunkLen. When BLOB is finished, io.EOF is returned with nil chunk. func (d *BlobDecoder) Next() (chunk []byte, err error) { diff --git a/go/cm/enc/chapoly/dem.go b/go/cm/enc/chapoly/dem.go index c2ec534..021a2b6 100644 --- a/go/cm/enc/chapoly/dem.go +++ b/go/cm/enc/chapoly/dem.go @@ -159,8 +159,8 @@ func do( if seal { n, errR = io.ReadFull(r, j.buf[PadLen:PadLen+ChunkLen]) } else { + blobDecoder.SetReadBuf(j.buf) chunk, errR = blobDecoder.Next() - copy(j.buf, chunk) n = len(chunk) j.buf = j.buf[:n] } -- 2.48.1