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

refactor: add bitwise_memcpy #567

Merged
merged 1 commit into from
Nov 22, 2024
Merged

refactor: add bitwise_memcpy #567

merged 1 commit into from
Nov 22, 2024

Conversation

gabriele-0201
Copy link
Contributor

@gabriele-0201 gabriele-0201 commented Nov 18, 2024

This pr not only extracts the shift and copy bits logic a new function(bitwise_mempcy), but also includes a slight update: now bitwise_memcpy leaves unchanged all the bits that are not part of the copy in the destination

edit. the pr now also includes a replacement of init with start every time it was not used correctly

Copy link
Contributor Author

gabriele-0201 commented Nov 18, 2024

Comment on lines 116 to 122
// Copy `source_bit_len` from the source bytes, starting from the `source_bit_init`ith bit
// within the first byte into the destination, starting from the `destination_bit_init`ith bit
//
// `destination` must be long enough to store the bits, accounting also possible shifts.
// `source` must have a length multiple of 8 bytes
//
// All the bits in `destination` not involved in the copy will be left unchanged.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not make it a rustdoc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No real reason, it's a mistake, it should be a rustdoc yes

@gabriele-0201 gabriele-0201 force-pushed the gm_quickcheck_tests_add_printlns branch from 14c01c5 to 21d5177 Compare November 19, 2024 08:46
@gabriele-0201 gabriele-0201 changed the base branch from gm_quickcheck_tests_add_printlns to master November 19, 2024 08:51
destination: &mut [u8],
destination_bit_init: usize,
source: &[u8],
source_bit_init: usize,
Copy link
Contributor

Choose a reason for hiding this comment

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

style: a slice start is usually referred to as "start" not "init". "init" implies that it's a value, not a position.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, yes, this makes perfect sense. I generally use them interchangeably, but now that I have a clearer idea, I will use them properly!

abstract copy and shift bits logic
@rphmeier rphmeier merged commit 8e9d992 into master Nov 22, 2024
8 checks passed
@rphmeier rphmeier deleted the gm_bitwise_memcpy branch November 22, 2024 20:14
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.

3 participants