Skip to content

Commit f3f7cc3

Browse files
Reduce number of as casts (image-rs#71)
1 parent 51e4232 commit f3f7cc3

File tree

5 files changed

+154
-115
lines changed

5 files changed

+154
-115
lines changed

src/decode/astc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{Channels, ColorFormat, NormConvert, WithPrecision};
77
// helpers
88

99
fn decode_astc_block<const PIXELS: usize, T: Default + Copy>(
10-
block_size: (usize, usize),
10+
block_size: (u8, u8),
1111
) -> impl Fn([u8; 16]) -> [[T; 4]; PIXELS]
1212
where
1313
u8: NormConvert<T>,
@@ -35,7 +35,7 @@ where
3535
});
3636
}
3737

38-
debug_assert_eq!(PIXELS, block_size.0 * block_size.1);
38+
debug_assert_eq!(PIXELS, block_size.0 as usize * block_size.1 as usize);
3939
let footprint = astc_decode::Footprint::new(block_size.0 as u32, block_size.1 as u32);
4040

4141
move |bytes| {
@@ -47,9 +47,9 @@ where
4747

4848
macro_rules! astc_decoder {
4949
($out:ty, $block_w:literal, $block_h:literal) => {{
50-
const BLOCK_WIDTH: usize = $block_w;
51-
const BLOCK_HEIGHT: usize = $block_h;
52-
const BLOCK_PIXELS: usize = BLOCK_WIDTH * BLOCK_HEIGHT;
50+
const BLOCK_WIDTH: u8 = $block_w;
51+
const BLOCK_HEIGHT: u8 = $block_h;
52+
const BLOCK_PIXELS: usize = BLOCK_WIDTH as usize * BLOCK_HEIGHT as usize;
5353
const BYTES_PER_BLOCK: usize = 16;
5454
const CHANNELS: usize = 4;
5555
type OutPixel = [$out; CHANNELS];

0 commit comments

Comments
 (0)