This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit 7b15fad6c3eeece124f635b7a5c2fd72443f2017 Author: Schamschi local <[email protected]> AuthorDate: Tue Jun 4 02:52:37 2019 +0200 NUMBERS-104: Speed up trial division (continued) Remove unreachable lines of code to increase test coverage as requested. --- .../org/apache/commons/numbers/primes/SmallPrimes.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 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 49041d9..77676a6 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 @@ -184,14 +184,12 @@ class SmallPrimes { int currentEquivalenceClassIndex = Arrays.binarySearch( PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue(), minFactor % m); - if (currentEquivalenceClassIndex < 0) { - if (currentEquivalenceClassIndex == -PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue().length - 1) { - km += m; - currentEquivalenceClassIndex = 0; - } else { - currentEquivalenceClassIndex = -(currentEquivalenceClassIndex + 1); - } - } + + /* + Since minFactor is the next smallest prime number after the + first 512 primes, it cannot be a multiple of one of them, therefore, + the index returned by the above binary search must be non-negative. + */ boolean done = false; while (!done) {
