diff options
| author | Paul Eggert | 2024-07-10 10:36:35 +0200 |
|---|---|---|
| committer | Paul Eggert | 2024-07-11 16:01:41 +0200 |
| commit | b6cbf0cbb66fa4c1a7f351350d5f9aed9c93cd26 (patch) | |
| tree | 3a514e2f76ba02af9a4f27b0ae7e41ae7eecb3c7 /src | |
| parent | abafc6ca01444de7aad9856b4901aa82a68dff32 (diff) | |
| download | emacs-b6cbf0cbb66fa4c1a7f351350d5f9aed9c93cd26.tar.gz emacs-b6cbf0cbb66fa4c1a7f351350d5f9aed9c93cd26.zip | |
In timefns, do gcd reduction more often
* src/timefns.c (ticks_hz_hz_ticks): Reduce by gcd
even if t.ticks is not a fixnum, since that’s easy.
Diffstat (limited to 'src')
| -rw-r--r-- | src/timefns.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/timefns.c b/src/timefns.c index 0df7d1f4363..ba1ba10a809 100644 --- a/src/timefns.c +++ b/src/timefns.c | |||
| @@ -774,8 +774,8 @@ ticks_hz_hz_ticks (struct ticks_hz t, Lisp_Object hz) | |||
| 774 | if (XFIXNUM (hz) <= 0) | 774 | if (XFIXNUM (hz) <= 0) |
| 775 | invalid_hz (hz); | 775 | invalid_hz (hz); |
| 776 | 776 | ||
| 777 | /* For speed, use intmax_t arithmetic if it will do. */ | 777 | /* Prefer non-bignum arithmetic to speed up common cases. */ |
| 778 | if (FASTER_TIMEFNS && FIXNUMP (t.ticks) && FIXNUMP (t.hz)) | 778 | if (FASTER_TIMEFNS && FIXNUMP (t.hz)) |
| 779 | { | 779 | { |
| 780 | /* Reduce T.hz and HZ by their GCD, to avoid some intmax_t | 780 | /* Reduce T.hz and HZ by their GCD, to avoid some intmax_t |
| 781 | overflows that would occur in T.ticks * HZ. */ | 781 | overflows that would occur in T.ticks * HZ. */ |
| @@ -784,9 +784,12 @@ ticks_hz_hz_ticks (struct ticks_hz t, Lisp_Object hz) | |||
| 784 | ithz /= d; | 784 | ithz /= d; |
| 785 | ihz /= d; | 785 | ihz /= d; |
| 786 | 786 | ||
| 787 | intmax_t ticks; | 787 | if (FIXNUMP (t.ticks)) |
| 788 | if (!ckd_mul (&ticks, XFIXNUM (t.ticks), ihz)) | 788 | { |
| 789 | return make_int (ticks / ithz - (ticks % ithz < 0)); | 789 | intmax_t ticks; |
| 790 | if (!ckd_mul (&ticks, XFIXNUM (t.ticks), ihz)) | ||
| 791 | return make_int (ticks / ithz - (ticks % ithz < 0)); | ||
| 792 | } | ||
| 790 | 793 | ||
| 791 | t.hz = make_fixnum (ithz); | 794 | t.hz = make_fixnum (ithz); |
| 792 | hz = make_fixnum (ihz); | 795 | hz = make_fixnum (ihz); |