You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2015/08/29 00:27:47 UTC

[2/3] [math] Fixed comparison pattern (FindBugs)

Fixed comparison pattern (FindBugs)


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/10dc13c8
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/10dc13c8
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/10dc13c8

Branch: refs/heads/master
Commit: 10dc13c80752b0489d291b54440212ca54c59fee
Parents: 392323e
Author: Gilles <er...@apache.org>
Authored: Sat Aug 29 00:03:03 2015 +0200
Committer: Gilles <er...@apache.org>
Committed: Sat Aug 29 00:03:03 2015 +0200

----------------------------------------------------------------------
 .../math4/fitting/GaussianCurveFitter.java      | 24 ++++++++------------
 1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/10dc13c8/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
index da6d46d..10b11f3 100644
--- a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
+++ b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
@@ -261,23 +261,17 @@ public class GaussianCurveFitter extends AbstractCurveFitter {
                     if (p2 == null) {
                         return 1;
                     }
-                    if (p1.getX() < p2.getX()) {
-                        return -1;
+                    int comp = Double.compare(p1.getX(), p2.getX());
+                    if (comp != 0) {
+                        return comp;
                     }
-                    if (p1.getX() > p2.getX()) {
-                        return 1;
+                    comp = Double.compare(p1.getY(), p2.getY());
+                    if (comp != 0) {
+                        return comp;
                     }
-                    if (p1.getY() < p2.getY()) {
-                        return -1;
-                    }
-                    if (p1.getY() > p2.getY()) {
-                        return 1;
-                    }
-                    if (p1.getWeight() < p2.getWeight()) {
-                        return -1;
-                    }
-                    if (p1.getWeight() > p2.getWeight()) {
-                        return 1;
+                    comp = Double.compare(p1.getWeight(), p2.getWeight());
+                    if (comp != 0) {
+                        return comp;
                     }
                     return 0;
                 }