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 ResolvableType.hashCode() for better performances #635

Closed
wants to merge 1 commit into from

Conversation

sdeleuze
Copy link
Contributor

Prior to this commit, when there was a lot of entries in the ResolvableType.cache HashMap,
getting a simple value could take a lot of time due to a lot of calls to ResolvableType.equals().
ResolvableType.equals() used this.type, getSource(), this.variableResolver.getSource() and
this.componentType, but ResolvableType.hashCode() used only this.type.

With this commit, ResolvableType.hashCode() now uses the same fields than ResolvableType.equals().

Performances on the spring-resolvabletype-benchmark project:

  • 8000 us before this commit
  • 120 us with this commit

Issue: SPR-12122

Prior to this commit, when there was a lot of entries in the ResolvableType.cache HashMap,
getting a simple value could take a lot of time due to a lot of calls to ResolvableType.equals().
ResolvableType.equals() used this.type, getSource(), this.variableResolver.getSource() and
this.componentType, but ResolvableType.hashCode() used only this.type.

With this commit, ResolvableType.hashCode() now uses the same fields than ResolvableType.equals().

Performances on the spring-resolvabletype-benchmark project:
 - 8000 us before this commit
 - 120 us with this commit

Issue: SPR-12122
@sdeleuze
Copy link
Contributor Author

Merged in master

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.

1 participant