You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/10/22 22:44:13 UTC

[GitHub] [commons-math] aherbert commented on a diff in pull request #226: Extract commons value.

aherbert commented on code in PR #226:
URL: https://github.com/apache/commons-math/pull/226#discussion_r1002593266


##########
commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java:
##########
@@ -403,14 +403,11 @@ private static void keepIfBetter(PointValuePair candidate,
             // List is not fully populated yet.
             for (PointValuePair p : list) {
                 final double[] pPoint = p.getPoint();
-                if (Arrays.equals(pPoint, candidatePoint)) {
-                    // Point was already stored.
-                    return;
-                } else {
+                if (!Arrays.equals(pPoint, candidatePoint)) {

Review Comment:
   This loop is a bug. There should not be two return statements in the for loop. The candidate should only be stored if it is not the same as all the values in the list. I have updated master with the fix.
   
   As for the rest of the changes these are all of the type:
   ```
   if () {
      x = ...
      return x
   } else {
      x = ...
      return x
   }
   ```
   to:
   ```
   if () {
      x = ...
   } else {
      x = ...
   }
   return x
   ```
   I do not see any benefit to this change. It introduces an extra jump condition for the first block which must jump then return, rather than just returning.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org