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

Java equals() should evaluate primitives first #244

Merged
merged 1 commit into from
Aug 28, 2019

Conversation

jparise
Copy link
Contributor

@jparise jparise commented Aug 28, 2019

This is an optimization for generated equals() methods that evaluates
the cheaper primitive comparisons before the more expensive complex
object comparisons.

This change also renames Schema.isObjCPrimitiveType to the more general
Schema.isPrimitiveType. It was already being used by both Objective-C
and JavaScript, and it's logic can also be applied to Java.

Closes #230

This is an optimization for generated equals() methods that evaluates
the cheaper primitive comparisons before the more expensive complex
object comparisons.

This change also renames Schema.isObjCPrimitiveType to the more general
Schema.isPrimitiveType. It was already being used by both Objective-C
and JavaScript, and it's logic can also be applied to Java.
@jparise jparise requested review from rahul-malik and RicoYao August 28, 2019 21:14
Copy link
Contributor

@RicoYao RicoYao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rahul-malik rahul-malik merged commit 9d367a5 into pinterest:master Aug 28, 2019
@jparise jparise deleted the equals-primitives branch August 28, 2019 22:29
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.

Java model builders should order the fields checked in equals()
3 participants