[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Tue Jul 29 22:23:49 UTC 2014


details:   /var/hg/gmp/rev/039e4fe83a58
changeset: 16462:039e4fe83a58
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Jul 30 00:23:26 2014 +0200
description:
mpq/cmp_[su]i.c: Remove a branch.

details:   /var/hg/gmp/rev/9e160b94cf3e
changeset: 16463:9e160b94cf3e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Jul 30 00:23:34 2014 +0200
description:
ChangeLog

diffstat:

 ChangeLog    |   3 +++
 mpq/cmp_si.c |  26 ++++++++++----------------
 mpq/cmp_ui.c |  11 ++++-------
 3 files changed, 17 insertions(+), 23 deletions(-)

diffs (97 lines):

diff -r bfc155c8a85f -r 9e160b94cf3e ChangeLog
--- a/ChangeLog	Mon Jul 28 22:06:42 2014 +0200
+++ b/ChangeLog	Wed Jul 30 00:23:34 2014 +0200
@@ -4,6 +4,9 @@
 	* mpz/fib2_ui.c: Use tabulated values, when available.
 	* mpz/fib_ui.c: #if HAVE_NATIVE_mpn_addlsh1_n, use it.
 
+	* mpq/cmp_ui.c: Remove a branch.
+	* mpq/cmp_si.c: Likewise.
+
 2014-07-27  Torbjörn Granlund  <tege at gmplib.org>
 
 	* mpn/x86/k7/gcd_1.asm: Use LEAL.
diff -r bfc155c8a85f -r 9e160b94cf3e mpq/cmp_si.c
--- a/mpq/cmp_si.c	Mon Jul 28 22:06:42 2014 +0200
+++ b/mpq/cmp_si.c	Wed Jul 30 00:23:34 2014 +0200
@@ -1,6 +1,6 @@
 /* _mpq_cmp_si -- compare mpq and long/ulong fraction.
 
-Copyright 2001, 2013 Free Software Foundation, Inc.
+Copyright 2001, 2013, 2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -42,26 +42,20 @@
   /* need canonical sign to get right result */
   ASSERT (SIZ(DEN(q)) > 0);
 
+  if (n >= 0)
+    return _mpq_cmp_ui (q, n, d);
   if (SIZ(NUM(q)) >= 0)
     {
-      if (n >= 0)
-        return _mpq_cmp_ui (q, n, d);            /* >=0 cmp >=0 */
-      else
-        return 1;                                /* >=0 cmp <0 */
+      return 1;                                /* >=0 cmp <0 */
     }
   else
     {
-      if (n >= 0)
-        return -1;                               /* <0 cmp >=0 */
-      else
-        {
-          mpq_t  qabs;
-          SIZ(NUM(qabs)) = ABSIZ(NUM(q));
-          PTR(NUM(qabs)) = PTR(NUM(q));
-          SIZ(DEN(qabs)) = SIZ(DEN(q));
-          PTR(DEN(qabs)) = PTR(DEN(q));
+      mpq_t  qabs;
+      SIZ(NUM(qabs)) = -SIZ(NUM(q));
+      PTR(NUM(qabs)) = PTR(NUM(q));
+      SIZ(DEN(qabs)) = SIZ(DEN(q));
+      PTR(DEN(qabs)) = PTR(DEN(q));
 
-          return - _mpq_cmp_ui (qabs, NEG_CAST (unsigned long, n), d);    /* <0 cmp <0 */
-        }
+      return - _mpq_cmp_ui (qabs, NEG_CAST (unsigned long, n), d);    /* <0 cmp <0 */
     }
 }
diff -r bfc155c8a85f -r 9e160b94cf3e mpq/cmp_ui.c
--- a/mpq/cmp_ui.c	Mon Jul 28 22:06:42 2014 +0200
+++ b/mpq/cmp_ui.c	Wed Jul 30 00:23:34 2014 +0200
@@ -2,7 +2,7 @@
    negative based on if U > V, U == V, or U < V.  Vn and Vd may have
    common factors.
 
-Copyright 1993, 1994, 1996, 2000-2003, 2005 Free Software Foundation, Inc.
+Copyright 1993, 1994, 1996, 2000-2003, 2005, 2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -63,12 +63,10 @@
   if (UNLIKELY (den2 == 0))
     DIVIDE_BY_ZERO;
 
-  if (num1_size == 0)
-    return -(num2 != 0);
-  if (num1_size < 0)
-    return num1_size;
   if (num2 == 0)
     return num1_size;
+  if (num1_size <= 0)
+    return -1;
 
   /* NUM1 x DEN2 is either TMP1_SIZE limbs or TMP1_SIZE-1 limbs.
      Same for NUM1 x DEN1 with respect to TMP2_SIZE.  */
@@ -80,8 +78,7 @@
     return -num1_size;
 
   TMP_MARK;
-  tmp1_ptr = TMP_ALLOC_LIMBS (num1_size + 1);
-  tmp2_ptr = TMP_ALLOC_LIMBS (den1_size + 1);
+  TMP_ALLOC_LIMBS_2 (tmp1_ptr, num1_size + 1, tmp2_ptr, den1_size + 1);
 
   cy_limb = mpn_mul_1 (tmp1_ptr, PTR(NUM(op1)), num1_size,
                        (mp_limb_t) den2);


More information about the gmp-commit mailing list