]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify fixnum division slightly
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 6 Nov 2019 19:47:39 +0000 (11:47 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 6 Nov 2019 19:48:23 +0000 (11:48 -0800)
* src/data.c (arith_driver): Streamline fixnum division a bit
more, and add a comment about why overflow is impossible.
This responds to a private comment by Stefan Monnier.

src/data.c

index 955e50739008cc8eaea27dbb00dc9c481bcfcc47..649dc174f901186f4c7d1dd8c968874b81b5829b 100644 (file)
@@ -2943,7 +2943,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
 
        /* Set ACCUM to the next operation's result if it fits,
           else exit the loop.  */
-       bool overflow = false;
+       bool overflow;
        intmax_t a;
        switch (code)
          {
@@ -2953,9 +2953,11 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
          case Adiv:
            if (next == 0)
              xsignal0 (Qarith_error);
-           eassert (! INT_DIVIDE_OVERFLOW (accum, next));
-           a = accum / next;
-           break;
+           /* This cannot overflow, as integer overflow can
+              occur only if the dividend is INTMAX_MIN, but
+              INTMAX_MIN < MOST_NEGATIVE_FIXNUM <= accum.  */
+           accum /= next;
+           continue;
          case Alogand: accum &= next; continue;
          case Alogior: accum |= next; continue;
          case Alogxor: accum ^= next; continue;