8000 Remove `object == this` "optimization" in `equals` methods · Issue #921 · jenetics/jenetics · GitHub
[go: up one dir, main page]

Skip to content

Remove object == this "optimization" in equals methods #921

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

Closed
jenetics opened this issue Oct 22, 2024 · 1 comment
Closed

Remove object == this "optimization" in equals methods #921

jenetics opened this issue Oct 22, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@jenetics
Copy link
Owner
jenetics commented Oct 22, 2024

Remove the object == this optimization, when implementing the equals methods. Modern JVMs no longer appreciate this kind of "optimizations".

Old

public boolean equals(final Object obj) {
    return obj == this ||
        obj instanceof DoubleRange other &&
        Double.compare(_min, other._min) == 0 &&
        Double.compare(_max, other._max) == 0;
}

New

public boolean equals(final Object obj) {
    return obj instanceof DoubleRange other &&
        Double.compare(_min, other._min) == 0 &&
        Double.compare(_max, other._max) == 0;
}
@jenetics jenetics added this to the v8.2.0 milestone Oct 22, 2024
@jenetics jenetics self-assigned this Oct 22, 2024
jenetics added a commit that referenced this issue Oct 22, 2024
Signed-off-by: Franz Wilhelmstötter <franz.wilhelmstoetter@gmail.com>
jenetics added a commit that referenced this issue Oct 22, 2024
…ls_optimization

#921: Remove `Object::equals` "optimizations".
@jenetics
Copy link
Owner Author

Merged into r8.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant
0