Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created October 27, 2022 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkomanov/60c0dd835159dd5ec4fcb28fe025e8e4 to your computer and use it in GitHub Desktop.
Save dkomanov/60c0dd835159dd5ec4fcb28fe025e8e4 to your computer and use it in GitHub Desktop.
#[no_mangle]
pub extern "system" fn decodeSimdNative(
_env: JNIEnv,
_class: JClass,
input: *const u8,
input_size: usize,
output: *mut u8,
output_size: usize,
) -> usize {
let (input_slice, output_slice) = unsafe {
(
from_raw_parts(input, input_size),
from_raw_parts_mut(output, output_size)
)
};
let result = base64_simd::URL_SAFE_NO_PAD.decode(
input_slice,
base64_simd::OutRef::from_slice(output_slice),
).unwrap();
result.len()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment