Reduce number of clones when processing jpeg data
This commit is contained in:
1 parent
592405268e
commit
eeb79ee07a
2 files changed
+7
-9
No files matched your search
+3
-4
@@ -1153,14 +1153,13 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
));
|
||||
}
|
||||
|
||||
// TODO: avoid this clone
|
||||
let jpeg_tables = decoder.image().jpeg_tables.clone();
|
||||
let photometric_interpretation = decoder.image().photometric_interpretation;
|
||||
|
||||
let jpeg_reader = JpegReader::new(
|
||||
&mut decoder.reader,
|
||||
compressed_length,
|
||||
&jpeg_tables,
|
||||
jpeg_tables,
|
||||
&photometric_interpretation,
|
||||
)?;
|
||||
let mut decoder = jpeg::Decoder::new(jpeg_reader);
|
||||
@@ -1248,14 +1247,14 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
TiffFormatError::InvalidTagValueType(Tag::JPEGTables),
|
||||
));
|
||||
}
|
||||
// TODO: avoid this clone
|
||||
|
||||
let jpeg_tables = self.image().jpeg_tables.clone();
|
||||
let photometric_interpretation = self.image().photometric_interpretation;
|
||||
|
||||
let jpeg_reader = JpegReader::new(
|
||||
&mut self.reader,
|
||||
length,
|
||||
&jpeg_tables,
|
||||
jpeg_tables,
|
||||
&photometric_interpretation,
|
||||
)?;
|
||||
let mut decoder = jpeg::Decoder::new(jpeg_reader);
|
||||
|
||||
@@ -208,7 +208,7 @@ impl JpegReader {
|
||||
pub fn new<R>(
|
||||
reader: &mut SmartReader<R>,
|
||||
length: u64,
|
||||
jpeg_tables: &Option<Vec<u8>>,
|
||||
jpeg_tables: Option<Vec<u8>>,
|
||||
photometric_interpretation: &PhotometricInterpretation,
|
||||
) -> io::Result<JpegReader>
|
||||
where
|
||||
@@ -220,11 +220,11 @@ impl JpegReader {
|
||||
reader.read_exact(&mut segment[..])?;
|
||||
|
||||
match jpeg_tables {
|
||||
Some(tables) => {
|
||||
Some(mut jpeg_data) => {
|
||||
assert!(
|
||||
tables.len() >= 2,
|
||||
jpeg_data.len() >= 2,
|
||||
"jpeg_tables, if given, must be at least 2 bytes long. Got {:?}",
|
||||
tables
|
||||
jpeg_data
|
||||
);
|
||||
|
||||
assert!(
|
||||
@@ -233,7 +233,6 @@ impl JpegReader {
|
||||
length
|
||||
);
|
||||
|
||||
let mut jpeg_data = tables.clone();
|
||||
if photometric_interpretation == &PhotometricInterpretation::RGB {
|
||||
add_app14segment(&mut jpeg_data, JpegTagApp14Transform::App14TransformUnknown)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user