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

[Deserialize] Split out peek logic from seed generic #1102

Closed
wants to merge 2 commits into from

Conversation

GnomedDev
Copy link

@GnomedDev GnomedDev commented Jan 6, 2024

Splits duplicated and somewhat complex logic depending on two generics (Read and seed) into only depending on one generic (Read) cutting debug mode llvm-lines output on my program by:

  • SeqAccess::next_element_seed: 34232 -> 21752
  • MapAccess::next_key_seed: 11225 -> 6722

src/de.rs Outdated Show resolved Hide resolved
Co-authored-by: David Tolnay <dtolnay@gmail.com>
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I think extracting a peek_next_elem function that is shared between SeqAccess and MapAccess is going to be counterproductive because it interferes with making more of the logic independent of the seed type. This PR is still leaving a significant amount of logic that is duplicated for each seed, as opposed to once per Read type.

Check out #1205 for a different approach that produces 25% smaller next_element_seed and next_key_seed functions compared to this one.

@GnomedDev GnomedDev deleted the size-opt branch October 19, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants