Skip to content

Commit ca89210

Browse files
committed
Address review and small fixups
Remove pattern of using slicing to do one bounds check now that arrays are being used. Break array::map function into its own line Write directly into array instead of indexing since the types match
1 parent 1d1bb95 commit ca89210

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/codecs/avif/decoder.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,7 @@ impl<R: Read> ImageDecoder for AvifDecoder<R> {
516516
self.process_16bit_picture(&mut aligned_store, yuv_range, matrix_strategy)?;
517517
let buf_chunks = buf.as_chunks_mut::<2>().0.iter_mut();
518518
for (dst, src) in buf_chunks.zip(aligned_store.iter()) {
519-
let bytes = src.to_ne_bytes();
520-
dst[0] = bytes[0];
521-
dst[1] = bytes[1];
519+
*dst = src.to_ne_bytes();
522520
}
523521
}
524522
}

src/imageops/fast_blur.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,10 @@ fn box_blur_horizontal_pass_impl<T, const CN: usize>(
332332
let dst_chunks = dst.as_chunks_mut::<CN>().0.iter_mut();
333333
let data_section_chunks = data_section.as_chunks::<CN>().0.iter();
334334
let advanced_kernel_part_chunks = advanced_kernel_part.as_chunks::<CN>().0.iter();
335-
for ((dst, src_previous), src_next) in dst_chunks
335+
for ((dst_chunk, src_previous), src_next) in dst_chunks
336336
.zip(data_section_chunks)
337337
.zip(advanced_kernel_part_chunks)
338338
{
339-
let dst_chunk = &mut dst[..CN];
340339
dst_chunk[0] = rounding_saturating_mul(weight0, weight);
341340
if CN > 1 {
342341
dst_chunk[1] = rounding_saturating_mul(weight1, weight);

src/imageops/filter_1d.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,12 @@ fn filter_symmetric_column<T, F, const N: usize>(
269269
}
270270
}
271271

272-
let shaped_dst0 = &mut chunk[..16];
272+
let (shaped_dst0, shaped_dst1) = chunk.split_at_mut(16);
273273

274274
for (src, dst) in store0.iter().zip(shaped_dst0.iter_mut()) {
275275
*dst = src.to_();
276276
}
277277

278-
let shaped_dst1 = &mut chunk[16..32];
279-
280278
for (src, dst) in store1.iter().zip(shaped_dst1.iter_mut()) {
281279
*dst = src.to_();
282280
}

src/imageops/sample.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,8 @@ where
15121512
let mut out = image.buffer_like();
15131513
let transient_dst_chunks = transient_dst.as_chunks_mut::<CN>().0.iter_mut();
15141514
for (dst, src) in out.pixels_mut().zip(transient_dst_chunks) {
1515-
*dst = *Pixel::from_slice(&src.map(|v| NumCast::from(FloatNearest(v)).unwrap()))
1515+
let pix = src.map(|v| NumCast::from(FloatNearest(v)).unwrap());
1516+
*dst = *Pixel::from_slice(&pix);
15161517
}
15171518

15181519
out

0 commit comments

Comments
 (0)