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

Optimize BeanMap#entrySet #33793

Closed

Conversation

gudrb33333
Copy link

Hello, I have been learning a lot while analyzing this open source project recently. During my analysis, I noticed a TODO message and came up with an simple idea.

  • Enhancing memory efficiency by setting the initial capacity of a HashMap.

I have read the contributor guidelines in detail, but there may still be some mistakes.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 25, 2024
@pivotal-cla
Copy link

@gudrb33333 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

1 similar comment
@pivotal-cla
Copy link

@gudrb33333 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@gudrb33333 Thank you for signing the Contributor License Agreement!

@bclozel bclozel added the in: core Issues in core modules (aop, beans, core, context, expression) label Oct 25, 2024
@sdeleuze
Copy link
Contributor

I see a remaining TODO: optimize on BeanMap#entrySet, couldn't we directly use Collections.unmodifiableSet() with a Set where we define the initial capacity and remove this TODO?

@sdeleuze sdeleuze changed the title Optimize entry set Optimize BeanMap#entrySet Oct 25, 2024
@gudrb33333
Copy link
Author

Do you mean using a Set directly without copying it into a HashMap?

@sdeleuze
Copy link
Contributor

Yes

@gudrb33333
Copy link
Author

I researched and discovered SimpleImmutableEntry, then modified the code to directly use Collections.unmodifiableSet().

@sdeleuze
Copy link
Contributor

Thanks, make sense, but I initially missed those changes were done on the CGLIB fork that is included in Spring Framework, and we prefer avoiding doing such refinement on the fork, so I will decline. Thanks for your understanding.

@sdeleuze sdeleuze closed this Oct 25, 2024
@sdeleuze sdeleuze added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 25, 2024
@gudrb33333
Copy link
Author

Thank you for the review! It was very motivating for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants