commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [40/50] commons-rng git commit: Unnecessary checks.
Date Mon, 21 Nov 2016 17:04:30 GMT
Unnecessary checks.

Class is internal (package private): a lower level exception is fine to signal
a programming error (within the library itself).


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/106d17cf
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/106d17cf
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/106d17cf

Branch: refs/heads/master
Commit: 106d17cf675ad95d0e8a816d85dc021ab692fab9
Parents: 1af0ab0
Author: Gilles <erans@apache.org>
Authored: Sun Nov 20 02:36:56 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Sun Nov 20 02:36:56 2016 +0100

----------------------------------------------------------------------
 .../rng/sampling/distribution/InternalUtils.java     | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/106d17cf/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
----------------------------------------------------------------------
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
index 4fcf591..11205bd 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
@@ -43,12 +43,6 @@ class InternalUtils { // Class is package-private on purpose; do not make
it pub
      * by a {@code long} (i.e. if {@code n > 20}).
      */
     public static long factorial(int n)  {
-        if (n < 0) {
-            throw new IllegalArgumentException(n + " < " + 0);
-        }
-        if (n > 20) {
-            throw new IllegalArgumentException(n + " > " + 20);
-        }
         return FACTORIALS[n];
     }
 
@@ -74,10 +68,6 @@ class InternalUtils { // Class is package-private on purpose; do not make
it pub
          */
         private FactorialLog(int numValues,
                              double[] cache) {
-            if (numValues < 0) {
-                throw new IllegalArgumentException(numValues + " < " + 0);
-            }
-
             LOG_FACTORIALS = new double[numValues];
 
             final int beginCopy = 2;
@@ -98,6 +88,7 @@ class InternalUtils { // Class is package-private on purpose; do not make
it pub
 
         /**
          * Creates an instance with no precomputed values.
+         *
          * @return an instance with no precomputed values.
          */
         public static FactorialLog create() {
@@ -124,10 +115,6 @@ class InternalUtils { // Class is package-private on purpose; do not
make it pub
          * @throws IllegalArgumentException if {@code n < 0}.
          */
         public double value(final int n) {
-            if (n < 0) {
-                throw new IllegalArgumentException(n + " < " + 0);
-            }
-
             // Use cache of precomputed values.
             if (n < LOG_FACTORIALS.length) {
                 return LOG_FACTORIALS[n];


Mime
View raw message