Skip to content

Commit d0d626a

Browse files
committed
hash_index() fix for big-endian
1 parent e74f88f commit d0d626a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pixel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ impl<const N: usize> Pixel<N> {
124124
{
125125
// credits for the initial idea: @zakarumych
126126
let v = if N == 4 {
127-
u32::from_ne_bytes(cast(self.0))
127+
u32::from_le_bytes(cast(self.0))
128128
} else {
129-
u32::from_ne_bytes([self.0[0], self.0[1], self.0[2], 0xff])
129+
u32::from_le_bytes([self.0[0], self.0[1], self.0[2], 0xff])
130130
} as u64;
131131
let s = ((v & 0xff00_ff00) << 32) | (v & 0x00ff_00ff);
132-
s.wrapping_mul(0x0300_0700_0005_000b_u64).to_le().swap_bytes() as u8 & 63
132+
(s.wrapping_mul(0x0300_0700_0005_000b_u64) >> 56) as u8 & 63
133133
}
134134

135135
#[inline]

0 commit comments

Comments
 (0)