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

Minor cleanups of equals and hashcode in core #142

Merged
merged 1 commit into from
May 11, 2020

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented May 11, 2020

Just a starter PR with some cleanups as I get to know the repo better :) In particular, I noticed the patterns were mixed within the module so this makes them consistent too.

Description of changes:

  • Use hashCode method instead of Objects.hash. The later has poor performance because it allocates a varargs array even for this single argument

  • instanceof instead of getClass() ==. Java 8+, which the module targets, performs better with instanceof, and the code is a bit cleaner to boot thanks to automatic null check. getClass could still be appropriate where a subclass really has to match a subclass, but this doesn't seem to be intended

  • Object.equals instead of a tree of null checks

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@willarmiros willarmiros 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 improvements!

@willarmiros willarmiros merged commit 26f9431 into aws:master May 11, 2020
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.

None yet

2 participants