pub fn uwuify_sse<'a>(
bytes: &[u8],
temp_bytes1: &'a mut [u8],
temp_bytes2: &'a mut [u8],
) -> &'a [u8] ⓘ
Expand description
uwuify some bytes
requires the sse4.1 x86 feature
temp_bytes1
and temp_bytes2
must be buffers of size round_up16(bytes.len()) * 16
,
because this is the worst-case size of the output. yes, it is annoying to allocate by
hand, but simd :)
the returned slice is the uwu’d result. when working with utf-8 strings, just pass in
the string as raw bytes and convert the output slice back to a string afterwards.
there’s also the uwuify_str_sse
function that is suitable for one-off use with a string slice
§example:
use uwuifier::{uwuify_sse, round_up16};
let s = "hello world";
let b = s.as_bytes();
let mut temp1 = vec![0u8; round_up16(b.len()) * 16];
let mut temp2 = vec![0u8; round_up16(b.len()) * 16];
let res = uwuify_sse(b, &mut temp1, &mut temp2);
assert_eq!(std::str::from_utf8(res).unwrap(), "hewwo wowwd");