From: Paul Eggert Date: Sun, 19 Aug 2018 06:06:41 +0000 (-0700) Subject: Tweak integer division X-Git-Tag: emacs-27.0.90~4541 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7ea369e5f22d6e3bcf1e55225c0ff356d9cabb2e;p=emacs.git 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. --- diff --git a/src/data.c b/src/data.c index 5ef0ef85571..8a6975da3ab 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); } }