suyashkumar / dicom

⚡High Performance DICOM Medical Image Parser in Go.
MIT License
933 stars 136 forks source link

If the passed in Reader is _also_ an io.Seeker, consider trying to use Seek() on Skip #263

Open suyashkumar opened 1 year ago

suyashkumar commented 1 year ago

If the reader we are reading from is also an io.Seeker, try to use Seek() on Skip (when skipping data, so we don't need to do reads). Using this in conjunction with a buffered Reader may be complex or require a custom implementation though for a small improvement.

This would be useful when parsing files from disk, but when reading from cloud storage I'm not sure most clients offer a Seeker interface (though it could be possible).

Since this is most likley to be used with PixelData anyway, and top-level PixelData should be the last tag in the DICOM, we could also consider just stopping alltogether when we hit a top-level PixelData tag (no need to read further). We would have to be careful about some things, like PixelData tags embedded within Sequences (e.g. Icons).