@@ -887,9 +887,9 @@ async fn read_tag_value(
887
887
// value fits in offset field
888
888
let res = cursor. read ( value_byte_length) . await ?;
889
889
if bigtiff {
890
- cursor. advance ( 8 - value_byte_length) ;
890
+ cursor. advance ( 8 - value_byte_length) ;
891
891
} else {
892
- cursor. advance ( 4 - value_byte_length) ;
892
+ cursor. advance ( 4 - value_byte_length) ;
893
893
}
894
894
res
895
895
} else {
@@ -899,7 +899,11 @@ async fn read_tag_value(
899
899
} else {
900
900
cursor. read_u32 ( ) . await ?. into ( )
901
901
} ;
902
- let reader = cursor. reader ( ) . get_bytes ( offset..offset+value_byte_length) . await ?. reader ( ) ;
902
+ let reader = cursor
903
+ . reader ( )
904
+ . get_bytes ( offset..offset + value_byte_length)
905
+ . await ?
906
+ . reader ( ) ;
903
907
EndianAwareReader :: new ( reader, cursor. endianness ( ) )
904
908
// cursor.seek(offset);
905
909
// cursor.read(value_byte_length).await?
@@ -934,18 +938,18 @@ async fn read_tag_value(
934
938
935
939
match tag_type {
936
940
Type :: BYTE | Type :: UNDEFINED => {
937
- let mut v = Vec :: new ( ) ;
941
+ let mut v = Vec :: with_capacity ( count as _ ) ;
938
942
for _ in 0 ..count {
939
943
v. push ( Value :: Byte ( data. read_u8 ( ) ?) ) ;
940
944
}
941
- return Ok ( Value :: List ( v) ) ;
945
+ Ok ( Value :: List ( v) )
942
946
}
943
947
Type :: SBYTE => {
944
- let mut v = Vec :: new ( ) ;
948
+ let mut v = Vec :: with_capacity ( count as _ ) ;
945
949
for _ in 0 ..count {
946
950
v. push ( Value :: SignedByte ( data. read_i8 ( ) ?) ) ;
947
951
}
948
- return Ok ( Value :: List ( v) ) ;
952
+ Ok ( Value :: List ( v) )
949
953
}
950
954
Type :: ASCII => {
951
955
let mut buf = vec ! [ 0 ; count as usize ] ;
@@ -954,95 +958,95 @@ async fn read_tag_value(
954
958
let v = std:: str:: from_utf8 ( & buf)
955
959
. map_err ( |err| AsyncTiffError :: General ( err. to_string ( ) ) ) ?;
956
960
let v = v. trim_matches ( char:: from ( 0 ) ) ;
957
- return Ok ( Value :: Ascii ( v. into ( ) ) ) ;
961
+ Ok ( Value :: Ascii ( v. into ( ) ) )
958
962
} else {
959
963
panic ! ( "Invalid tag" ) ;
960
964
// return Err(TiffError::FormatError(TiffFormatError::InvalidTag));
961
965
}
962
966
}
963
967
Type :: SHORT => {
964
- let mut v = Vec :: new ( ) ;
968
+ let mut v = Vec :: with_capacity ( count as _ ) ;
965
969
for _ in 0 ..count {
966
970
v. push ( Value :: Short ( data. read_u16 ( ) ?) ) ;
967
971
}
968
- return Ok ( Value :: List ( v) ) ;
972
+ Ok ( Value :: List ( v) )
969
973
}
970
974
Type :: SSHORT => {
971
- let mut v = Vec :: new ( ) ;
975
+ let mut v = Vec :: with_capacity ( count as _ ) ;
972
976
for _ in 0 ..count {
973
977
v. push ( Value :: Signed ( i32:: from ( data. read_i16 ( ) ?) ) ) ;
974
978
}
975
- return Ok ( Value :: List ( v) ) ;
979
+ Ok ( Value :: List ( v) )
976
980
}
977
981
Type :: LONG => {
978
- let mut v = Vec :: new ( ) ;
982
+ let mut v = Vec :: with_capacity ( count as _ ) ;
979
983
for _ in 0 ..count {
980
984
v. push ( Value :: Unsigned ( data. read_u32 ( ) ?) ) ;
981
985
}
982
- return Ok ( Value :: List ( v) ) ;
986
+ Ok ( Value :: List ( v) )
983
987
}
984
988
Type :: SLONG => {
985
- let mut v = Vec :: new ( ) ;
989
+ let mut v = Vec :: with_capacity ( count as _ ) ;
986
990
for _ in 0 ..count {
987
991
v. push ( Value :: Signed ( data. read_i32 ( ) ?) ) ;
988
992
}
989
- return Ok ( Value :: List ( v) ) ;
993
+ Ok ( Value :: List ( v) )
990
994
}
991
995
Type :: FLOAT => {
992
- let mut v = Vec :: new ( ) ;
996
+ let mut v = Vec :: with_capacity ( count as _ ) ;
993
997
for _ in 0 ..count {
994
998
v. push ( Value :: Float ( data. read_f32 ( ) ?) ) ;
995
999
}
996
- return Ok ( Value :: List ( v) ) ;
1000
+ Ok ( Value :: List ( v) )
997
1001
}
998
1002
Type :: DOUBLE => {
999
1003
let mut v = Vec :: with_capacity ( count as _ ) ;
1000
1004
for _ in 0 ..count {
1001
1005
v. push ( Value :: Double ( data. read_f64 ( ) ?) )
1002
1006
}
1003
- return Ok ( Value :: List ( v) ) ;
1007
+ Ok ( Value :: List ( v) )
1004
1008
}
1005
1009
Type :: RATIONAL => {
1006
1010
let mut v = Vec :: with_capacity ( count as _ ) ;
1007
1011
for _ in 0 ..count {
1008
1012
v. push ( Value :: Rational ( data. read_u32 ( ) ?, data. read_u32 ( ) ?) )
1009
1013
}
1010
- return Ok ( Value :: List ( v) ) ;
1014
+ Ok ( Value :: List ( v) )
1011
1015
}
1012
1016
Type :: SRATIONAL => {
1013
1017
let mut v = Vec :: with_capacity ( count as _ ) ;
1014
1018
for _ in 0 ..count {
1015
1019
v. push ( Value :: SRational ( data. read_i32 ( ) ?, data. read_i32 ( ) ?) )
1016
1020
}
1017
- return Ok ( Value :: List ( v) ) ;
1021
+ Ok ( Value :: List ( v) )
1018
1022
}
1019
1023
Type :: LONG8 => {
1020
1024
let mut v = Vec :: with_capacity ( count as _ ) ;
1021
1025
for _ in 0 ..count {
1022
1026
v. push ( Value :: UnsignedBig ( data. read_u64 ( ) ?) )
1023
1027
}
1024
- return Ok ( Value :: List ( v) ) ;
1028
+ Ok ( Value :: List ( v) )
1025
1029
}
1026
1030
Type :: SLONG8 => {
1027
1031
let mut v = Vec :: with_capacity ( count as _ ) ;
1028
1032
for _ in 0 ..count {
1029
1033
v. push ( Value :: SignedBig ( data. read_i64 ( ) ?) )
1030
1034
}
1031
- return Ok ( Value :: List ( v) ) ;
1035
+ Ok ( Value :: List ( v) )
1032
1036
}
1033
1037
Type :: IFD => {
1034
1038
let mut v = Vec :: with_capacity ( count as _ ) ;
1035
1039
for _ in 0 ..count {
1036
1040
v. push ( Value :: Ifd ( data. read_u32 ( ) ?) )
1037
1041
}
1038
- return Ok ( Value :: List ( v) ) ;
1042
+ Ok ( Value :: List ( v) )
1039
1043
}
1040
1044
Type :: IFD8 => {
1041
1045
let mut v = Vec :: with_capacity ( count as _ ) ;
1042
1046
for _ in 0 ..count {
1043
1047
v. push ( Value :: IfdBig ( data. read_u64 ( ) ?) )
1044
1048
}
1045
- return Ok ( Value :: List ( v) ) ;
1049
+ Ok ( Value :: List ( v) )
1046
1050
}
1047
1051
}
1048
1052
}
0 commit comments