You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/04/29 00:48:11 UTC

svn commit: r1476850 - /commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java

Author: sebb
Date: Sun Apr 28 22:48:08 2013
New Revision: 1476850

URL: http://svn.apache.org/r1476850
Log:
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.

Modified:
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java?rev=1476850&r1=1476849&r2=1476850&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java Sun Apr 28 22:48:08 2013
@@ -278,10 +278,10 @@ public class ComparatorChain<E> implemen
             if (retval != 0) {
                 // invert the order if it is a reverse sort
                 if (orderingBits.get(comparatorIndex) == true) {
-                    if (Integer.MIN_VALUE == retval) {
-                        retval = Integer.MAX_VALUE;
+                    if (retval > 0) {
+                        retval = -1;
                     } else {
-                        retval *= -1;
+                        retval = 1;
                     }
                 }
                 return retval;