Repository navigation
Compare boxed values by value in Java - #851
Merged
Merged
Conversation
We represent the integers, the floats and the booleans as ``Long``'s, ``Double``'s and ``Boolean``'s in the arguments, the properties and the collections, so ``==`` and ``!=`` compared the references of two such values. This worked only by chance for the ``Long``'s between -128 and 127, which Java caches, and practically never for the ``Double``'s. We now unbox the left operand, *e.g.*, ``(long) child.getAOnly() == childCopy.getAOnly()``, unless an operand is a literal, an arithmetic result or a length, which are primitives already.
Coverage Report for CI Build 38802716091Coverage at 90.149% (no base build to compare)Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We represent the integers, the floats and the booleans as
Long's,Double's andBoolean's in the arguments, the properties and the collections, so==and!=compared the references of two such values. This worked only by chance for theLong's between -128 and 127, which Java caches, and practically never for theDouble's.We now unbox the left operand, e.g.,
(long) child.getAOnly() == childCopy.getAOnly(), unless an operand is a literal, an arithmetic result or a length, which are primitives already.