Skip to content

Commit

Permalink
remove unnecessary buffer allocation in image writer
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomanski committed Sep 17, 2022
1 parent 2c55b0f commit 85afb8b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions image_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,6 @@ func writeAll(w io.Writer, itemsToWrite *list.List) error {

// WriteTo writes the image to the given WriterAt
func (iw *ImageWriter) WriteTo(w io.Writer, volumeIdentifier string) error {
buffer := make([]byte, sectorSize)
var err error

now := time.Now()

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

if buffer, err = pvd.MarshalBinary(); err != nil {
buffer, err := pvd.MarshalBinary()
if err != nil {
return err
}
if _, err = w.Write(buffer); err != nil {
Expand Down

0 comments on commit 85afb8b

Please sign in to comment.