[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 2f7ca40 3/5: Tweak integer mod performance
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 2f7ca40 3/5: Tweak integer mod performance |
Date: |
Sat, 24 Aug 2019 18:55:17 -0400 (EDT) |
branch: master
commit 2f7ca4020e4f1e30b263758439dba55551f0675d
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Tweak integer mod performance
* src/data.c (integer_mod): Use mpz_tdiv_r not mpz_mod, as that’s
more similar to the fixnum case, is a bit more efficient, and
otherwise the later ‘sgn_r < 0’ code is useless anyway.
---
src/data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/data.c b/src/data.c
index dfc8a89..cb25fce 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3098,7 +3098,7 @@ integer_mod (Lisp_Object x, Lisp_Object y)
{
mpz_t const *ym = bignum_integer (&mpz[1], y);
bool neg_y = mpz_sgn (*ym) < 0;
- mpz_mod (mpz[0], *bignum_integer (&mpz[0], x), *ym);
+ mpz_tdiv_r (mpz[0], *bignum_integer (&mpz[0], x), *ym);
/* Fix the sign if needed. */
int sgn_r = mpz_sgn (mpz[0]);