diff options
| author | Paul Eggert | 2024-07-10 10:23:31 +0200 |
|---|---|---|
| committer | Paul Eggert | 2024-07-11 16:01:41 +0200 |
| commit | abafc6ca01444de7aad9856b4901aa82a68dff32 (patch) | |
| tree | e93ca0808068bf57f19624bc5d727ac2676d2d25 /src | |
| parent | 6ef052d9b23aef3f34d19e5d93d97884215d1465 (diff) | |
| download | emacs-abafc6ca01444de7aad9856b4901aa82a68dff32.tar.gz emacs-abafc6ca01444de7aad9856b4901aa82a68dff32.zip | |
In timefns, prefer ui mul and div
* src/timefns.c (ticks_hz_hz_ticks): If the multiplier
is a fixnum that fits in unsigned long, use mpz_mul_ui
instead of the more-expensive mpz_mul. Similarly, if the
divisor is a fixnum that fits in unsigned long, use
mpz_fdiv_q_ui instead of mpz_fdiv_q.
Diffstat (limited to 'src')
| -rw-r--r-- | src/timefns.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/timefns.c b/src/timefns.c index 0a34bda28c7..0df7d1f4363 100644 --- a/src/timefns.c +++ b/src/timefns.c | |||
| @@ -796,10 +796,15 @@ ticks_hz_hz_ticks (struct ticks_hz t, Lisp_Object hz) | |||
| 796 | invalid_hz (hz); | 796 | invalid_hz (hz); |
| 797 | 797 | ||
| 798 | /* Fall back on bignum arithmetic. */ | 798 | /* Fall back on bignum arithmetic. */ |
| 799 | mpz_mul (mpz[0], | 799 | mpz_t const *zticks = bignum_integer (&mpz[0], t.ticks); |
| 800 | *bignum_integer (&mpz[0], t.ticks), | 800 | if (FASTER_TIMEFNS && FIXNUMP (hz) && XFIXNUM (hz) <= ULONG_MAX) |
| 801 | *bignum_integer (&mpz[1], hz)); | 801 | mpz_mul_ui (mpz[0], *zticks, XFIXNUM (hz)); |
| 802 | mpz_fdiv_q (mpz[0], mpz[0], *bignum_integer (&mpz[1], t.hz)); | 802 | else |
| 803 | mpz_mul (mpz[0], *zticks, *bignum_integer (&mpz[1], hz)); | ||
| 804 | if (FASTER_TIMEFNS && FIXNUMP (t.hz) && XFIXNUM (t.hz) <= ULONG_MAX) | ||
| 805 | mpz_fdiv_q_ui (mpz[0], mpz[0], XFIXNUM (t.hz)); | ||
| 806 | else | ||
| 807 | mpz_fdiv_q (mpz[0], mpz[0], *bignum_integer (&mpz[1], t.hz)); | ||
| 803 | return make_integer_mpz (); | 808 | return make_integer_mpz (); |
| 804 | } | 809 | } |
| 805 | 810 | ||