message: Add further optimizations to cmyk_to_rgb function, thanks to
diff: @@ -84,26 +84,28 @@ impl<'a, R: 'a + Read> ImageDecoder<'a> for JpegDecoder<R> {
  }
  }
  -fn cmyk_to_rgb(input: &[u8]) -> Vec<u8> {
  - let size = input.len() - input.len() / 4;
  - let mut output = Vec::with_capacity(size);
  +pub fn cmyk_to_rgb(input: &[u8]) -> Vec<u8> {
  + let count = input.len()/4;
  + let mut output = vec![0; 3*count];
  +
  + let in_pixels = input[..4*count].chunks_exact(4);
  + let out_pixels = output[..3*count].chunks_exact_mut(3);
  let inv = 1.0/255.0;
  - for pixel in input.chunks(4) {
  - let c = f32::from(pixel[0]);
  - let m = f32::from(pixel[1]);
  - let y = f32::from(pixel[2]);
  - let k = 255.0 - f32::from(pixel[3]);
  + for (pixel, outp) in in_pixels.zip(out_pixels) {
  + let c = 255 - u16::from(pixel[0]);
  + let m = 255 - u16::from(pixel[1]);
  + let y = 255 - u16::from(pixel[2]);
  + let k = 255 - u16::from(pixel[3]);
  - let k_mul = k * 255.0;
  // CMY -> RGB
  - let r = (k_mul - c * k) * inv;
  - let g = (k_mul - m * k) * inv;
  - let b = (k_mul - y * k) * inv;
  + let r = (k * c) as f32 * inv;
  + let g = (k * m) as f32 * inv;
  + let b = (k * y) as f32 * inv;
  - output.push(r as u8);
  - output.push(g as u8);
  - output.push(b as u8);
  + outp[0] = r as u8;
  + outp[1] = g as u8;
  + outp[2] = b as u8;
  }
  output
  