-
Notifications
You must be signed in to change notification settings - Fork 2k
fix: Inline value match in SparseTrie::find_leaf to remove redundant wrapper #19138
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
This was already the case as far as I can tell |
| expected_value: Option<&Vec<u8>>, | ||
| ) -> Result<LeafLookup, LeafLookupError> { | ||
| // Helper function to check if a value matches the expected value | ||
| fn check_value_match( |
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.
can we just add an #[inline] attribute here? It doesn't clone the value unless the error is returned anyway, as @mediocregopher said.
|
@shekhirin any updates yet? |
crates/trie/sparse/src/trie.rs
Outdated
| self.rlp_buf.clear(); | ||
| } | ||
|
|
||
| #[inline] |
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.
sorry, I meant adding an #[inline] attribute on check_value_match, and that's basically the only change that's needed in this PR, because we already don't clone anything until we return the error
Description
Replace local helper function
check_value_matchwith inlined comparison inSparseTrie::find_leaf.Avoids a redundant wrapper and defers cloning
Vec<u8>until error construction.Rationale: