Skip to content

Commit 85afb8b

Browse files
committed
remove unnecessary buffer allocation in image writer
1 parent 2c55b0f commit 85afb8b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

image_writer.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,6 @@ func writeAll(w io.Writer, itemsToWrite *list.List) error {
538538

539539
// WriteTo writes the image to the given WriterAt
540540
func (iw *ImageWriter) WriteTo(w io.Writer, volumeIdentifier string) error {
541-
buffer := make([]byte, sectorSize)
542-
var err error
543-
544541
now := time.Now()
545542

546543
wc := writeContext{
@@ -618,7 +615,8 @@ func (iw *ImageWriter) WriteTo(w io.Writer, volumeIdentifier string) error {
618615
}
619616
}
620617

621-
if buffer, err = pvd.MarshalBinary(); err != nil {
618+
buffer, err := pvd.MarshalBinary()
619+
if err != nil {
622620
return err
623621
}
624622
if _, err = w.Write(buffer); err != nil {

0 commit comments

Comments
 (0)