No need to exactly invert whatever value is returned, especially as the Javadoc says we only return -1, 0 or +1.

This fixes Findbugs complaint about checking compareTo with a specific value, as well as avoiding a multiplication.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1476850 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2013-04-28 22:48:08 +00:00
parent e7ae9283ba
commit feb7b2fe0c
1 changed files with 3 additions and 3 deletions

View File

@ -278,10 +278,10 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
if (retval != 0) { if (retval != 0) {
// invert the order if it is a reverse sort // invert the order if it is a reverse sort
if (orderingBits.get(comparatorIndex) == true) { if (orderingBits.get(comparatorIndex) == true) {
if (Integer.MIN_VALUE == retval) { if (retval > 0) {
retval = Integer.MAX_VALUE; retval = -1;
} else { } else {
retval *= -1; retval = 1;
} }
} }
return retval; return retval;