[Gmp-commit] /var/hg/gmp: oddfac_1.c: remove unecessary if.

mercurial at gmplib.org mercurial at gmplib.org
Wed Apr 25 12:54:06 CEST 2012


details:   /var/hg/gmp/rev/c2ef37aa58ce
changeset: 14892:c2ef37aa58ce
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Apr 25 12:54:03 2012 +0200
description:
oddfac_1.c: remove unecessary if.

diffstat:

 mpz/oddfac_1.c |  16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diffs (59 lines):

diff -r 2ec2d1ad4f9e -r c2ef37aa58ce mpz/oddfac_1.c
--- a/mpz/oddfac_1.c	Wed Apr 25 12:38:39 2012 +0200
+++ b/mpz/oddfac_1.c	Wed Apr 25 12:54:03 2012 +0200
@@ -174,7 +174,7 @@
   mp_limb_t prod, max_prod;
   mp_size_t j;
 
-  ASSERT (n >= 15);
+  ASSERT (n >= 26);
 
   j = 0;
   prod  = -(n & 1);
@@ -187,10 +187,10 @@
   SWING_A_PRIME (3, n, prod, max_prod, factors, j);
 
   /* Swing primes from 5 to n/3 */
-  if (1 || n > 5*3) {
+  {
     mp_limb_t s;
 
-    if (1 || n >= 5*5) {
+    {
       mp_limb_t prime;
 
       s = limb_apprsqrt(n);
@@ -200,21 +200,19 @@
       SWING_A_PRIME (prime, n, prod, max_prod, factors, j);
       LOOP_ON_SIEVE_END;
       s++;
-    } else
-      s = n_to_bit (5);
+    }
 
     ASSERT (max_prod <= GMP_NUMB_MAX / 3);
-    max_prod *= 3;
     ASSERT (bit_to_n (s) * bit_to_n (s) > n);
     ASSERT (s <= n_to_bit (n / 3));
     {
       mp_limb_t prime;
+      mp_limb_t l_max_prod = max_prod * 3;
 
       LOOP_ON_SIEVE_BEGIN (prime, s, n_to_bit (n/3), 0, sieve);
-      SH_SWING_A_PRIME (prime, n, prod, max_prod, factors, j);
+      SH_SWING_A_PRIME (prime, n, prod, l_max_prod, factors, j);
       LOOP_ON_SIEVE_END;
     }
-    max_prod /= 3;
   }
 
   /* Store primes from (n+1)/2 to n */
@@ -225,7 +223,7 @@
     LOOP_ON_SIEVE_END;
   }
 
-  if (j != 0)
+  if (LIKELY (j != 0))
     {
       factors[j++] = prod;
       mpz_prodlimbs (x, factors, j);


More information about the gmp-commit mailing list