-
Notifications
You must be signed in to change notification settings - Fork 1
Fix decode strategy when splitting a chunk #3
8000 New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@cfcosta, is this failure of the build being caused by a formatting issue? Below is the log i get from
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice! just a little nitpicks.
@@ -142,6 +142,22 @@ fn decode_hex_nibble(n: u8x16) -> Result<u8x16, Error> { | |||
Ok(result) | |||
} | |||
|
|||
#[inline] | |||
fn nibble_chunck(chunk: &[u8]) -> (u8x16, u8x16) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nibble_chunk
#[inline] | ||
fn nibble_chunck(chunk: &[u8]) -> (u8x16, u8x16) { | ||
let parsed_chunk = u8x32::from_slice(chunk); | ||
let mut high_bytes_vec: Vec<u8> = vec![]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using vec to allocate on the heap, can we just set [u8; X]
directly? that way we don't need to allocate memory.
This PR 8000 fixes the remainig failing test in CI.
The
encode
function creates its 2x bytes output by merging 2 vectors of x bytes intercalating the values by if the index is even or odd. However, in thedecode
function splits the same 2 x bytes vector by just cutting it in half. That difference in strategy on splitting those larger vector seems to be the cause of the failing test.This PR adds new function
nibble_chunk
that splits a larger vector in 2 smaller vectors using the even/odd strategy from theencode
function.