emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 7ea369e: Tweak integer division


From: Paul Eggert
Subject: [Emacs-diffs] master 7ea369e: Tweak integer division
Date: Sun, 19 Aug 2018 02:07:05 -0400 (EDT)

branch: master
commit 7ea369e5f22d6e3bcf1e55225c0ff356d9cabb2e
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Tweak integer division
    
    * src/data.c (arith_driver): Reorder to remove unnecessary
    FIXNUMP.  Tighten test for whether to convert the divisor from
    fixnum to mpz_t.  Simplify.
---
 src/data.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/data.c b/src/data.c
index 5ef0ef8..8a6975d 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2896,11 +2896,11 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args)
            {
              /* Note that a bignum can never be 0, so we don't need
                 to check that case.  */
-             if (FIXNUMP (val) && XFIXNUM (val) == 0)
-               xsignal0 (Qarith_error);
              if (BIGNUMP (val))
                mpz_tdiv_q (accum, accum, XBIGNUM (val)->value);
-              else if (sizeof (EMACS_INT) > sizeof (long))
+             else if (XFIXNUM (val) == 0)
+               xsignal0 (Qarith_error);
+             else if (ULONG_MAX < -MOST_NEGATIVE_FIXNUM)
                 {
                   mpz_t tem;
                   mpz_init (tem);
@@ -2911,11 +2911,8 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args)
              else
                {
                  EMACS_INT value = XFIXNUM (val);
-                 bool negate = value < 0;
-                 if (negate)
-                   value = -value;
-                 mpz_tdiv_q_ui (accum, accum, value);
-                 if (negate)
+                 mpz_tdiv_q_ui (accum, accum, eabs (value));
+                 if (value < 0)
                    mpz_neg (accum, accum);
                }
            }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]