]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid possibly unnecessary lisp_time_struct call
authorPhilip Kaludercic <philipk@posteo.net>
Thu, 14 Apr 2022 09:00:07 +0000 (11:00 +0200)
committerPhilip Kaludercic <philipk@posteo.net>
Thu, 14 Apr 2022 16:39:35 +0000 (18:39 +0200)
* timefns.c (time_cmp): Defer the calculation of the time struct, in
  case A and B are eq to one another.

src/timefns.c

index 9e8592d35ac9516a7c53fb17ac1c0712794edaf7..6cfb787af8fab5c3cfd1e306bd99c3d7d419760c 100644 (file)
@@ -1219,8 +1219,6 @@ time_cmp (Lisp_Object a, Lisp_Object b)
       return da < db ? -1 : da != db;
     }
 
-  struct lisp_time ta = lisp_time_struct (a, 0);
-
   /* Compare nil to nil correctly, and handle other eq values quicker
      while we're at it.  Compare here rather than earlier, to handle
      NaNs and check formats.  */
@@ -1229,6 +1227,7 @@ time_cmp (Lisp_Object a, Lisp_Object b)
 
   /* Compare (ATICKS . AZ) to (BTICKS . BHZ) by comparing
      ATICKS * BHZ to BTICKS * AHZ.  */
+  struct lisp_time ta = lisp_time_struct (a, 0);
   struct lisp_time tb = lisp_time_struct (b, 0);
   mpz_t const *za = bignum_integer (&mpz[0], ta.ticks);
   mpz_t const *zb = bignum_integer (&mpz[1], tb.ticks);