summaryrefslogtreecommitdiff
path: root/mpz/gcd.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2016-12-29 00:41:34 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2016-12-29 00:41:34 +0100
commit84dc1bbab976aa9cc2bc6bd49e62a565591e9be4 (patch)
treee47bc9849c05d91fa59c44f26d68b012893dbe12 /mpz/gcd.c
parent68a29f31b42e95e4464797886f01e7f82e77d146 (diff)
downloadgmp-84dc1bbab976aa9cc2bc6bd49e62a565591e9be4.tar.gz
mpz/gcd.c: Reorder branches
Diffstat (limited to 'mpz/gcd.c')
-rw-r--r--mpz/gcd.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/mpz/gcd.c b/mpz/gcd.c
index 9cae9be81..b97e0204e 100644
--- a/mpz/gcd.c
+++ b/mpz/gcd.c
@@ -89,12 +89,12 @@ mpz_gcd (mpz_ptr g, mpz_srcptr u, mpz_srcptr v)
TMP_MARK;
/* Eliminate low zero bits from U and V and move to temporary storage. */
- while (*up == 0)
- up++;
- u_zero_limbs = up - PTR(u);
- usize -= u_zero_limbs;
- count_trailing_zeros (u_zero_bits, *up);
tp = up;
+ while (*tp == 0)
+ tp++;
+ u_zero_limbs = tp - up;
+ usize -= u_zero_limbs;
+ count_trailing_zeros (u_zero_bits, *tp);
up = TMP_ALLOC_LIMBS (usize);
if (u_zero_bits != 0)
{
@@ -104,12 +104,12 @@ mpz_gcd (mpz_ptr g, mpz_srcptr u, mpz_srcptr v)
else
MPN_COPY (up, tp, usize);
- while (*vp == 0)
- vp++;
- v_zero_limbs = vp - PTR (v);
- vsize -= v_zero_limbs;
- count_trailing_zeros (v_zero_bits, *vp);
tp = vp;
+ while (*tp == 0)
+ tp++;
+ v_zero_limbs = tp - vp;
+ vsize -= v_zero_limbs;
+ count_trailing_zeros (v_zero_bits, *tp);
vp = TMP_ALLOC_LIMBS (vsize);
if (v_zero_bits != 0)
{
@@ -124,15 +124,13 @@ mpz_gcd (mpz_ptr g, mpz_srcptr u, mpz_srcptr v)
g_zero_limbs = v_zero_limbs;
g_zero_bits = v_zero_bits;
}
- else if (u_zero_limbs < v_zero_limbs)
- {
- g_zero_limbs = u_zero_limbs;
- g_zero_bits = u_zero_bits;
- }
- else /* Equal. */
+ else
{
g_zero_limbs = u_zero_limbs;
- g_zero_bits = MIN (u_zero_bits, v_zero_bits);
+ if (u_zero_limbs < v_zero_limbs)
+ g_zero_bits = u_zero_bits;
+ else /* Equal. */
+ g_zero_bits = MIN (u_zero_bits, v_zero_bits);
}
/* Call mpn_gcd. The 2nd argument must not have more bits than the 1st. */