Skip to content

Commit

Permalink
Reduce allocations during readNativeFrames with frame channel
Browse files Browse the repository at this point in the history
  • Loading branch information
segmed-lam committed Nov 7, 2023
1 parent 8f1f151 commit 5006dd8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions read.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ func (r *reader) readPixelData(vl uint32, d *Dataset, fc chan<- *frame.Frame) (V

if fc != nil {
fc <- &f
} else {
image.Frames = append(image.Frames, &f)
}

image.Frames = append(image.Frames, &f)
}
image.IntentionallySkipped = r.opts.skipPixelData
return &pixelDataValue{PixelDataInfo: image}, nil
Expand Down Expand Up @@ -482,9 +482,10 @@ func (r *reader) readNativeFrames(parsedData *Dataset, fc chan<- *frame.Frame, v
currentFrame.NativeData.Data[pixel] = buf[pixel*samplesPerPixel : (pixel+1)*samplesPerPixel]
}
}
image.Frames[frameIdx] = &currentFrame
if fc != nil {
fc <- &currentFrame // write the current frame to the frame channel
} else {
image.Frames[frameIdx] = &currentFrame
}
}
if skipFinalPaddingByte {
Expand Down

0 comments on commit 5006dd8

Please sign in to comment.