From 23fe194ad9c09b306ee26b4952da536af0bb882f Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Thu, 6 Jan 2022 22:47:37 -0500 Subject: [PATCH] Remove read_ifd_offset_nonrepeating --- src/decoder/mod.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index a355327..4743b9a 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -811,15 +811,6 @@ impl Decoder { self.reader.byte_order } - fn read_ifd_offset_nonrepeating(&mut self) -> TiffResult { - let result = self.read_ifd_offset()?; - if self.seen_ifds.insert(result) { - Ok(result) - } else { - Err(TiffError::FormatError(TiffFormatError::CycleInOffsets)) - } - } - #[inline] pub fn read_ifd_offset(&mut self) -> Result { if self.bigtiff { @@ -978,9 +969,13 @@ impl Decoder { }; dir.insert(tag, entry); } - self.next_ifd = match self.read_ifd_offset_nonrepeating()? { - 0 => None, - n => Some(n), + + self.next_ifd = { + let result = self.read_ifd_offset()?; + if !self.seen_ifds.insert(result) { + return Err(TiffError::FormatError(TiffFormatError::CycleInOffsets)); + } + Some(result) }; Ok(dir) }