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

perf: optimize usize::MAX check in get_byte #5

Merged
merged 1 commit into from
Feb 26, 2024
Merged

Conversation

DaniPopes
Copy link
Member

No description provided.

@@ -399,7 +399,7 @@ impl Nibbles {
/// ```
#[inline]
pub fn get_byte(&self, i: usize) -> Option<u8> {
if i.checked_add(1)? < self.len() {
if (i < usize::MAX) & (i.wrapping_add(1) < self.len()) {
Copy link
Member

Choose a reason for hiding this comment

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

unpack pls why is this an optimization

Copy link
Member Author

Choose a reason for hiding this comment

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

No branch

@DaniPopes DaniPopes merged commit c2a84cc into master Feb 26, 2024
16 checks passed
@DaniPopes DaniPopes deleted the dani/perf-get_byte branch February 26, 2024 11:29
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