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

Improve ObjectUtils#nullSafeEquals method for readability and performance #33626

Conversation

nomoreFt
Copy link
Contributor

@nomoreFt nomoreFt commented Oct 1, 2024

Description:

This pull request simplifies the nullSafeEquals method to improve readability and performance.

Changes:

Reorganized if conditions for clarity and reduced redundancy.
Optimized the array comparison logic for early termination when possible.
Removed unnecessary equals checks, making the flow more efficient.

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

bclozel commented Oct 2, 2024

Thanks for the proposal, but I don't think this will improve performance as advertized, quite the opposite. This skips the equals check in favor of array class checks.

@bclozel bclozel closed this Oct 2, 2024
@bclozel bclozel 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 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants