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

Reduce allocations when decoding maps #94

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

rukai
Copy link
Collaborator

@rukai rukai commented Oct 9, 2024

This PR alters the decode logic for maps to avoid reallocations due to map growth from insertions.
By using iterators + collect the size of the allocation required for the IndexMap is known up front, avoiding the need for reallocations as decoded items are inserted to the map.

This should give a small speed up to decoding of produce messages since they use maps.

Copy link
Owner

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

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

Makes sense!

@tychedelia tychedelia merged commit b7d36ee into tychedelia:main Oct 9, 2024
3 checks passed
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