Skip to content

Commit 83368db

Browse files
authored
Merge pull request #127 from lovasoa/optimize-data-copy
Optimize data copy
2 parents 2b0ed38 + 7608000 commit 83368db

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/decoder.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,11 @@ fn compute_image(components: &[Component],
788788
let line_stride = component.block_size.width as usize * component.dct_scale;
789789

790790
for y in 0 .. height {
791-
for x in 0 .. width {
792-
buffer[y * width + x] = data[0][y * line_stride + x];
793-
}
791+
let destination_idx = y * width;
792+
let source_idx = y * line_stride;
793+
let destination = &mut buffer[destination_idx..][..width];
794+
let source = &data[0][source_idx..][..width];
795+
destination.copy_from_slice(source);
794796
}
795797

796798
Ok(buffer)

0 commit comments

Comments
 (0)