[libmath-prime-util-perl] 29/54: Slight speedup

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:52:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.38
in repository libmath-prime-util-perl.

commit 4133fac1d739577c5fd227e4816a7730226ff533
Author: Dana Jacobsen <dana at acm.org>
Date:   Thu Feb 13 18:14:51 2014 -0800

    Slight speedup
---
 factor.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/factor.c b/factor.c
index cf028e6..29c3c7f 100644
--- a/factor.c
+++ b/factor.c
@@ -75,6 +75,7 @@ int factor(UV n, UV *factors)
           n /= f;
         }
       }
+      f = primes_small[sp];
     }
   }
   if (n < f*f) {
@@ -84,7 +85,7 @@ int factor(UV n, UV *factors)
   }
   /* Perfect squares and cubes.  Factor root only once. */
   {
-    int i, j, k = is_power(n,2) ? 2 : is_power(n,3) ? 3 : 1;
+    int i, j, k = is_power(n,2) ? 2 : (n >= f*f*f && is_power(n,3)) ? 3 : 1;
     if (k > 1) {
       UV p = (k == 2) ? isqrt(n) : icbrt(n);
       if (is_prob_prime(p)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list