[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b6cbf0cbb66 10/17: In timefns, do gcd reduction more often
From: |
Paul Eggert |
Subject: |
master b6cbf0cbb66 10/17: In timefns, do gcd reduction more often |
Date: |
Thu, 11 Jul 2024 10:01:58 -0400 (EDT) |
branch: master
commit b6cbf0cbb66fa4c1a7f351350d5f9aed9c93cd26
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
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.
---
src/timefns.c | 13 ++++++++-----
1 file 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)
if (XFIXNUM (hz) <= 0)
invalid_hz (hz);
- /* For speed, use intmax_t arithmetic if it will do. */
- if (FASTER_TIMEFNS && FIXNUMP (t.ticks) && FIXNUMP (t.hz))
+ /* Prefer non-bignum arithmetic to speed up common cases. */
+ if (FASTER_TIMEFNS && FIXNUMP (t.hz))
{
/* Reduce T.hz and HZ by their GCD, to avoid some intmax_t
overflows that would occur in T.ticks * HZ. */
@@ -784,9 +784,12 @@ ticks_hz_hz_ticks (struct ticks_hz t, Lisp_Object hz)
ithz /= d;
ihz /= d;
- intmax_t ticks;
- if (!ckd_mul (&ticks, XFIXNUM (t.ticks), ihz))
- return make_int (ticks / ithz - (ticks % ithz < 0));
+ if (FIXNUMP (t.ticks))
+ {
+ intmax_t ticks;
+ if (!ckd_mul (&ticks, XFIXNUM (t.ticks), ihz))
+ return make_int (ticks / ithz - (ticks % ithz < 0));
+ }
t.hz = make_fixnum (ithz);
hz = make_fixnum (ihz);
- master 2fb7bb41bee 11/17: In timefns, call natnump only for non-fixnums, (continued)
- master 2fb7bb41bee 11/17: In timefns, call natnump only for non-fixnums, Paul Eggert, 2024/07/11
- master 1c8e64a9536 12/17: New FASTER_BIGNUM macro to test slow-path code, Paul Eggert, 2024/07/11
- master 0c850df888e 13/17: Optimize smallish mpz to native int conversion, Paul Eggert, 2024/07/11
- master 5e8a38ecb2a 07/17: Rename timefns internals, Paul Eggert, 2024/07/11
- master a6a3f322453 06/17: Speed up decode-time when not doing subseconds, Paul Eggert, 2024/07/11
- master 6ef052d9b23 08/17: Reduce size of integer product in timefns, Paul Eggert, 2024/07/11
- master abafc6ca014 09/17: In timefns, prefer ui mul and div, Paul Eggert, 2024/07/11
- master 75f53d7c2c1 14/17: In timefns.c avoid by-hand overflow checking, Paul Eggert, 2024/07/11
- master c3e6923b004 17/17: Rename timefns static function lisp_time_struct, Paul Eggert, 2024/07/11
- master e8b3c4cb58c 15/17: Decode current time directly to timespec, Paul Eggert, 2024/07/11
- master b6cbf0cbb66 10/17: In timefns, do gcd reduction more often,
Paul Eggert <=
- master e30706fd12b 16/17: Avoid mpz for some common timestamp cases, Paul Eggert, 2024/07/11
- master 35365620e4c 01/17: Refactor timefns more functionally, Paul Eggert, 2024/07/11