]> Cypherpunks repositories - keks.git/commitdiff
Tiny optimisation
authorSergey Matveev <stargrave@stargrave.org>
Sat, 15 Feb 2025 08:42:57 +0000 (11:42 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 15 Feb 2025 08:42:57 +0000 (11:42 +0300)
go/blob.go
go/cm/enc/chapoly/dem.go

index 8f1c71c8bad8f6471001398bee786b4a9d1395629fc486e3b7a03f475af592a9..ee45abb89b08366b35424f7ce5bdb81d7f81e2952f7b4309e1b6b24adddc3878 100644 (file)
@@ -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) {
index c2ec534c40fdca92ce8237e2fbbf2c2f6217e3a61de875bd6d259d30ca2d804f..021a2b697004109f9e4959840848cf38d9175d46f44e266ccbf9546391513526 100644 (file)
@@ -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]
                }