]> git.eshelyaron.com Git - emacs.git/commitdiff
Tweak integer division
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Aug 2018 06:06:41 +0000 (23:06 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Aug 2018 06:07:00 +0000 (23:07 -0700)
* 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

index 5ef0ef85571d235bd2a3833225745ebfc605c0f7..8a6975da3aba178885bab6d6c965d1a985d1a83c 100644 (file)
@@ -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);
                }
            }