Skip to content

Conversation

@anim001k
Copy link
Contributor

Description

  • Replace local helper function check_value_match with inlined comparison in SparseTrie::find_leaf.

  • Avoids a redundant wrapper and defers cloning Vec<u8> until error construction.

  • Rationale:

    • Reduces cognitive load and eliminates local duplication without changing behavior.
    • Keeps clones only on error path; hot path unaffected.

@mediocregopher
Copy link
Collaborator

defers cloning Vec until error construction.

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(
Copy link
Collaborator

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.

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Oct 21, 2025
@anim001k anim001k requested a review from shekhirin October 21, 2025 07:46
@anim001k
Copy link
Contributor Author

@shekhirin any updates yet?

self.rlp_buf.clear();
}

#[inline]
Copy link
Collaborator

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

@anim001k anim001k requested a review from shekhirin October 24, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants