Skip to content

Commit feefadd

Browse files
committed
small changes to decrease diff size
1 parent b0bddcf commit feefadd

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

src/ifd.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,6 @@ impl ImageFileDirectory {
839839

840840
/// Read a single tag from the cursor
841841
async fn read_tag(cursor: &mut AsyncCursor, bigtiff: bool) -> AsyncTiffResult<(Tag, Value)> {
842-
// let start_cursor_position = cursor.position();
843-
844842
let tag_name = Tag::from_u16_exhaustive(cursor.read_u16().await?);
845843

846844
let tag_type_code = cursor.read_u16().await?;
@@ -855,10 +853,6 @@ async fn read_tag(cursor: &mut AsyncCursor, bigtiff: bool) -> AsyncTiffResult<(T
855853

856854
let tag_value = read_tag_value(cursor, tag_type, count, bigtiff).await?;
857855

858-
// TODO: better handle management of cursor state <- should be done now
859-
// let ifd_entry_size = if bigtiff { 20 } else { 12 };
860-
// cursor.seek(start_cursor_position + ifd_entry_size);
861-
862856
Ok((tag_name, tag_value))
863857
}
864858

@@ -878,7 +872,17 @@ async fn read_tag_value(
878872
return Ok(Value::List(vec![]));
879873
}
880874

881-
let tag_size = tag_type.size();
875+
let tag_size = match tag_type {
876+
Type::BYTE | Type::SBYTE | Type::ASCII | Type::UNDEFINED => 1,
877+
Type::SHORT | Type::SSHORT => 2,
878+
Type::LONG | Type::SLONG | Type::FLOAT | Type::IFD => 4,
879+
Type::LONG8
880+
| Type::SLONG8
881+
| Type::DOUBLE
882+
| Type::RATIONAL
883+
| Type::SRATIONAL
884+
| Type::IFD8 => 8,
885+
};
882886

883887
let value_byte_length = count.checked_mul(tag_size).unwrap();
884888

@@ -901,12 +905,10 @@ async fn read_tag_value(
901905
};
902906
let reader = cursor
903907
.reader()
904-
.get_bytes(offset..offset + value_byte_length)
908+
.get_metadata_bytes(offset..offset + value_byte_length)
905909
.await?
906910
.reader();
907911
EndianAwareReader::new(reader, cursor.endianness())
908-
// cursor.seek(offset);
909-
// cursor.read(value_byte_length).await?
910912
};
911913
// Case 2: there is one value.
912914
if count == 1 {

src/tiff/tags.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,6 @@ pub enum Type(u16) {
175175
}
176176
}
177177

178-
impl Type {
179-
pub const fn size(&self) -> u64 {
180-
match self {
181-
Type::BYTE | Type::SBYTE | Type::ASCII | Type::UNDEFINED => 1,
182-
Type::SHORT | Type::SSHORT => 2,
183-
Type::LONG | Type::SLONG | Type::FLOAT | Type::IFD => 4,
184-
Type::LONG8
185-
| Type::SLONG8
186-
| Type::DOUBLE
187-
| Type::RATIONAL
188-
| Type::SRATIONAL
189-
| Type::IFD8 => 8,
190-
}
191-
}
192-
}
193-
194178
tags! {
195179
/// See [TIFF compression tags](https://www.awaresystems.be/imaging/tiff/tifftags/compression.html)
196180
/// for reference.

0 commit comments

Comments
 (0)