mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 16:02:59 +01:00
aling mask to 8 bytes
This commit is contained in:
parent
717602472a
commit
02dd5375a9
@ -26,36 +26,33 @@ fn apply_mask_fast32(buf: &mut [u8], mask_u32: u32) {
|
|||||||
let mut len = buf.len();
|
let mut len = buf.len();
|
||||||
|
|
||||||
// Possible first unaligned block.
|
// Possible first unaligned block.
|
||||||
let head = min(len, (4 - (ptr as usize & 3)) & 3);
|
let head = min(len, (8 - (ptr as usize & 0x7)) & 0x3);
|
||||||
let mask_u32 = if head > 0 {
|
let mask_u32 = if head > 0 {
|
||||||
unsafe {
|
let n = if head > 4 { head - 4 } else { head };
|
||||||
xor_mem(ptr, mask_u32, head);
|
|
||||||
ptr = ptr.offset(head as isize);
|
|
||||||
}
|
|
||||||
len -= head;
|
|
||||||
//let mask_u32 =
|
|
||||||
if cfg!(target_endian = "big") {
|
|
||||||
mask_u32.rotate_left(8 * head as u32)
|
|
||||||
} else {
|
|
||||||
mask_u32.rotate_right(8 * head as u32)
|
|
||||||
}//;
|
|
||||||
|
|
||||||
/*
|
let mask_u32 = if n > 0 {
|
||||||
let head = min(len, (4 - (ptr as usize & 3)) & 3);
|
|
||||||
if head > 0 {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
xor_mem(ptr, mask_u32, head);
|
xor_mem(ptr, mask_u32, n);
|
||||||
ptr = ptr.offset(head as isize);
|
ptr = ptr.offset(head as isize);
|
||||||
}
|
}
|
||||||
len -= head;
|
len -= n;
|
||||||
if cfg!(target_endian = "big") {
|
if cfg!(target_endian = "big") {
|
||||||
mask_u32.rotate_left(8 * head as u32)
|
mask_u32.rotate_left(8 * n as u32)
|
||||||
} else {
|
} else {
|
||||||
mask_u32.rotate_right(8 * head as u32)
|
mask_u32.rotate_right(8 * n as u32)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mask_u32
|
mask_u32
|
||||||
}*/
|
};
|
||||||
|
|
||||||
|
if head > 4 {
|
||||||
|
unsafe {
|
||||||
|
*(ptr as *mut u32) ^= mask_u32;
|
||||||
|
ptr = ptr.offset(4);
|
||||||
|
len -= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mask_u32
|
||||||
} else {
|
} else {
|
||||||
mask_u32
|
mask_u32
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user