Skip to content

Minor cleanups of equals and hashcode in core - #142

Merged
willarmiros merged 1 commit into
aws:masterfrom
anuraaga:instanceof-equals
May 11, 2020
Merged

Minor cleanups of equals and hashcode in core#142
willarmiros merged 1 commit into
aws:masterfrom
anuraaga:instanceof-equals

Conversation

@anuraaga

@anuraaga anuraaga commented May 11, 2020

Copy link
Copy Markdown
Contributor

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.

@willarmiros willarmiros left a comment

Copy link
Copy Markdown
Contributor

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.

2 participants