aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorPaul Eggert2019-11-06 11:47:39 -0800
committerPaul Eggert2019-11-06 11:48:23 -0800
commitb5bcc6f9ea23118f7d181c2dcdf17eb03b200be8 (patch)
treec996017a09fbb6366bbf4be45a6388b1eddb1465 /src/data.c
parent4ad6c932a826c2928ac82e56e5ae541eff7e5ca7 (diff)
downloademacs-b5bcc6f9ea23118f7d181c2dcdf17eb03b200be8.tar.gz
emacs-b5bcc6f9ea23118f7d181c2dcdf17eb03b200be8.zip
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.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/data.c b/src/data.c
index 955e5073900..649dc174f90 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2943,7 +2943,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
2943 2943
2944 /* Set ACCUM to the next operation's result if it fits, 2944 /* Set ACCUM to the next operation's result if it fits,
2945 else exit the loop. */ 2945 else exit the loop. */
2946 bool overflow = false; 2946 bool overflow;
2947 intmax_t a; 2947 intmax_t a;
2948 switch (code) 2948 switch (code)
2949 { 2949 {
@@ -2953,9 +2953,11 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
2953 case Adiv: 2953 case Adiv:
2954 if (next == 0) 2954 if (next == 0)
2955 xsignal0 (Qarith_error); 2955 xsignal0 (Qarith_error);
2956 eassert (! INT_DIVIDE_OVERFLOW (accum, next)); 2956 /* This cannot overflow, as integer overflow can
2957 a = accum / next; 2957 occur only if the dividend is INTMAX_MIN, but
2958 break; 2958 INTMAX_MIN < MOST_NEGATIVE_FIXNUM <= accum. */
2959 accum /= next;
2960 continue;
2959 case Alogand: accum &= next; continue; 2961 case Alogand: accum &= next; continue;
2960 case Alogior: accum |= next; continue; 2962 case Alogior: accum |= next; continue;
2961 case Alogxor: accum ^= next; continue; 2963 case Alogxor: accum ^= next; continue;