Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B8A4C200BCA for ; Mon, 21 Nov 2016 18:04:03 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B6FD6160B1C; Mon, 21 Nov 2016 17:04:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0FA73160AEF for ; Mon, 21 Nov 2016 18:04:02 +0100 (CET) Received: (qmail 56833 invoked by uid 500); 21 Nov 2016 17:03:54 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 54388 invoked by uid 99); 21 Nov 2016 17:03:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Nov 2016 17:03:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C67A7F1713; Mon, 21 Nov 2016 17:03:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: erans@apache.org To: commits@commons.apache.org Date: Mon, 21 Nov 2016 17:04:30 -0000 Message-Id: <402126634b9441068f3f838f5d8de20c@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [40/50] commons-rng git commit: Unnecessary checks. archived-at: Mon, 21 Nov 2016 17:04:03 -0000 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 Authored: Sun Nov 20 02:36:56 2016 +0100 Committer: Gilles 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];