From 2f7ca4020e4f1e30b263758439dba55551f0675d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 24 Aug 2019 12:45:36 -0700 Subject: [PATCH] Tweak integer mod performance MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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 dfc8a892f5e..cb25fce014a 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]); -- 2.39.2