Skip to content

Commit

Permalink
filesync: reuse data buffer for diffcopy
Browse files Browse the repository at this point in the history
Reuse the bytes message data buffer for diffcopy to allow memory to be
reused when unmarshaling the bytes.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
  • Loading branch information
jsternberg committed Oct 21, 2024
1 parent f835dd4 commit c902997
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion session/filesync/diffcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ func syncTargetDiffCopy(ds grpc.ServerStream, dest string) error {
}

func writeTargetFile(ds grpc.ServerStream, wc io.WriteCloser) error {
var bm BytesMessage
for {
bm := BytesMessage{}
bm.Data = bm.Data[:0]
if err := ds.RecvMsg(&bm); err != nil {
if errors.Is(err, io.EOF) {
return nil
Expand Down

0 comments on commit c902997

Please sign in to comment.