emacs-diffs
[Top][All Lists]
Advanced

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

master b5bcc6f: Simplify fixnum division slightly


From: Paul Eggert
Subject: master b5bcc6f: Simplify fixnum division slightly
Date: Wed, 6 Nov 2019 14:48:28 -0500 (EST)

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

    Simplify fixnum division slightly
    
    * 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 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/data.c b/src/data.c
index 955e507..649dc17 100644
--- a/src/data.c
+++ b/src/data.c
@@ -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;



reply via email to

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