commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1295559 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
Date Thu, 01 Mar 2012 13:49:02 GMT
Author: erans
Date: Thu Mar  1 13:49:01 2012
New Revision: 1295559

URL: http://svn.apache.org/viewvc?rev=1295559&view=rev
Log:
According to "FindBugs", negating the result of "compareTo" is bad
practice: Fixed.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java?rev=1295559&r1=1295558&r2=1295559&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
Thu Mar  1 13:49:01 2012
@@ -160,17 +160,17 @@ public class MathArrays {
                                       boolean strict) {
         Comparable previous = val[0];
         final int max = val.length;
-        int comp;
         for (int i = 1; i < max; i++) {
+            final int comp;
             switch (dir) {
             case INCREASING:
-                comp = -val[i].compareTo(previous);
+                comp = previous.compareTo(val[i]);
                 if (strict) {
-                    if (0 <= comp) {
+                    if (comp >= 0) {
                         return false;
                     }
                 } else {
-                    if ( comp > 0) {
+                    if (comp > 0) {
                         return false;
                     }
                 }



Mime
View raw message