Skip to content

Commit 324dee9

Browse files
committed
use safe chunking for aarch64 too
https://godbolt.org/z/PY8M3zWo8
1 parent 44b4ca3 commit 324dee9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

zlib-rs/src/deflate/compare256.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ mod neon {
119119
/// Behavior is undefined if the `neon` target feature is not enabled
120120
#[target_feature(enable = "neon")]
121121
pub unsafe fn compare256(src0: &[u8; 256], src1: &[u8; 256]) -> usize {
122-
let src0: &[[u8; 16]; 16] = unsafe { core::mem::transmute(src0) };
123-
let src1: &[[u8; 16]; 16] = unsafe { core::mem::transmute(src1) };
122+
let src0 = src0.chunks_exact(16);
123+
let src1 = src1.chunks_exact(16);
124124

125125
let mut len = 0;
126126

127-
for (a, b) in src0.iter().zip(src1) {
127+
for (a, b) in src0.zip(src1) {
128128
unsafe {
129129
let a: uint8x16_t = vld1q_u8(a.as_ptr());
130130
let b: uint8x16_t = vld1q_u8(b.as_ptr());

0 commit comments

Comments
 (0)