Use Vec::drain to avoid an extra memory allocation.

This commit is contained in:
KAMADA Ken'ichi 2020-02-05 23:05:10 +09:00
parent af94ad50b6
commit bc0053a2e7
1 changed files with 2 additions and 1 deletions

View File

@ -92,7 +92,8 @@ fn get_exif_attr_sub<R>(reader: &mut R)
let mut seg = Vec::new();
reader.by_ref().take(seglen as u64 - 2).read_to_end(&mut seg)?;
if code == marker::APP1 && seg.starts_with(&EXIF_ID) {
return Ok(seg.split_off(EXIF_ID.len()));
seg.drain(..EXIF_ID.len());
return Ok(seg);
}
if code == marker::SOS {
// Skipping the scan data is handled in the main loop,