|
|
|
@ -23,8 +23,8 @@ fn apply_mask_fallback(buf: &mut [u8], mask: [u8; 4]) { |
|
|
|
|
pub fn apply_mask_fast32(buf: &mut [u8], mask: [u8; 4]) { |
|
|
|
|
let mask_u32 = u32::from_ne_bytes(mask); |
|
|
|
|
|
|
|
|
|
let (mut prefix, words, mut suffix) = unsafe { buf.align_to_mut::<u32>() }; |
|
|
|
|
apply_mask_fallback(&mut prefix, mask); |
|
|
|
|
let (prefix, words, suffix) = unsafe { buf.align_to_mut::<u32>() }; |
|
|
|
|
apply_mask_fallback(prefix, mask); |
|
|
|
|
let head = prefix.len() & 3; |
|
|
|
|
let mask_u32 = if head > 0 { |
|
|
|
|
if cfg!(target_endian = "big") { |
|
|
|
@ -38,7 +38,7 @@ pub fn apply_mask_fast32(buf: &mut [u8], mask: [u8; 4]) { |
|
|
|
|
for word in words.iter_mut() { |
|
|
|
|
*word ^= mask_u32; |
|
|
|
|
} |
|
|
|
|
apply_mask_fallback(&mut suffix, mask_u32.to_ne_bytes()); |
|
|
|
|
apply_mask_fallback(suffix, mask_u32.to_ne_bytes()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg(test)] |
|
|
|
|