]> git.eshelyaron.com Git - emacs.git/commitdiff
Tweak integer mod performance
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Aug 2019 19:45:36 +0000 (12:45 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Aug 2019 22:55:09 +0000 (15:55 -0700)
* 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

index dfc8a892f5e685bef357084e55da8abe2ab41963..cb25fce014ac267c9a2d2644f2e775d2ee6f601e 100644 (file)
@@ -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]);