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

merkle::get<K>: use Nibbles #210

Merged
merged 2 commits into from
Aug 22, 2023
Merged

merkle::get<K>: use Nibbles #210

merged 2 commits into from
Aug 22, 2023

Conversation

rkuris
Copy link
Collaborator

@rkuris rkuris commented Aug 22, 2023

Should be a good speedup

Should be a good speedup
Some(c) => c,
None => return Ok(None),
},
NodeType::Leaf(n) => {
if chunks[i..] != *n.0 {
if !key_nibbles.iter().skip(i).eq(n.0.iter().cloned()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't these cloned be copied?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought so too, but apparently cloned() on an iterator changes an iterator over &T to T per the docs so what is really happening here is this is just converting the &u8 to a hard u8 for comparison.

Here is the implementation of clone() for all primitive types source and it's marked #[always_inline] so it's basically just a dereference...

                    fn clone(&self) -> Self {
                        *self
                    }

@rkuris rkuris merged commit 14150fa into main Aug 22, 2023
5 checks passed
@rkuris rkuris deleted the rkuris/get-nibbled branch August 22, 2023 22:27
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