emacs-diffs
[Top][All Lists]
Advanced

[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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]