Skip to content
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

read with padding and specialize u8 #2

Conversation

sharksforarms
Copy link

@sharksforarms sharksforarms commented Sep 30, 2022

this passes the tests, but there are some improvements to be made I think regarding the macro handling (duplicated code for specializing u8, we can probably split this out) as well as figuring out where those alloc/realloc is coming from (edit: this was from my debugging printlns oops)

let bytes: &[u8] = bit_slice.as_raw_slice();
let pad = 8 * ((bit_slice.len() + 7) / 8) - bit_slice.len();

// TODO: mention that this is slow? a conditional should be fast...
Copy link
Author

@sharksforarms sharksforarms Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, I don't think this path is slow (it's just comparing numbers), I think it's more-so the allocation that we save with the specialization of bytes (try running test_alloc with the changes in this branch on master, we save an alloc + realloc)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

@wcampbell0x2a wcampbell0x2a merged commit a456a61 into wcampbell0x2a:specialize-bytes Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants