commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [38/53] [abbrv] [math] MATH-1339.
Date Thu, 21 Apr 2016 23:15:24 GMT
MATH-1339.

Avoid unnecessary object creations and method calls.


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

Branch: refs/heads/develop
Commit: 55fd738c86ea1796d5152d818ab4b5060bb11803
Parents: 8081493
Author: Gilles <erans@apache.org>
Authored: Sun Mar 13 03:06:34 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Mon Mar 21 00:36:55 2016 +0100

----------------------------------------------------------------------
 src/main/java/org/apache/commons/math4/util/MathArrays.java | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/55fd738c/src/main/java/org/apache/commons/math4/util/MathArrays.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/util/MathArrays.java b/src/main/java/org/apache/commons/math4/util/MathArrays.java
index c50f44c..bb18a2b 100644
--- a/src/main/java/org/apache/commons/math4/util/MathArrays.java
+++ b/src/main/java/org/apache/commons/math4/util/MathArrays.java
@@ -1617,8 +1617,7 @@ public class MathArrays {
                 if (i == start) {
                     target = start;
                 } else {
-                    // NumberIsTooLargeException cannot occur.
-                    target = new UniformIntegerDistribution(rng, start, i).sample();
+                    target = rng.nextInt(i - start + 1) + start;
                 }
                 final int temp = list[target];
                 list[target] = list[i];
@@ -1632,8 +1631,7 @@ public class MathArrays {
                 if (i == start) {
                     target = start;
                 } else {
-                    // NumberIsTooLargeException cannot occur.
-                    target = new UniformIntegerDistribution(rng, i, start).sample();
+                    target = rng.nextInt(start - i + 1) + i;
                 }
                 final int temp = list[target];
                 list[target] = list[i];


Mime
View raw message