You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2024/07/05 14:08:08 UTC

(commons-numbers) 12/31: Remove unreachable code

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit e3fe38bdf6961b235de0c4c915ab827744026f65
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Jul 5 10:24:10 2024 +0100

    Remove unreachable code
---
 .../main/java/org/apache/commons/numbers/primes/SmallPrimes.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
index 8acd0684..2e78d938 100644
--- a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
+++ b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
@@ -212,9 +212,9 @@ final class SmallPrimes {
                 }
             }
         }
-        if (n != 1) {
-            factors.add(n);
-        }
+        // Note: When this method is used after the small trial division n != 1
+        // for all n in [2, MAX_VALUE] (tested using an exhaustive enumeration).
+        factors.add(n);
         return n;
     }