aboutsummaryrefslogtreecommitdiffstats
path: root/src/timefns.c
diff options
context:
space:
mode:
authorPaul Eggert2022-06-15 23:08:03 -0500
committerPaul Eggert2022-06-15 23:27:07 -0500
commit9bce1f3d7019f00f7c1c889d8be7832e9b645bec (patch)
tree201c5cf39cfaae24eda2755e2712da7624f90032 /src/timefns.c
parent16ee227c18db0d70d9a3e97230119464924797cc (diff)
downloademacs-9bce1f3d7019f00f7c1c889d8be7832e9b645bec.tar.gz
emacs-9bce1f3d7019f00f7c1c889d8be7832e9b645bec.zip
Prefer BASE_EQ in time-sensitive ops
* src/timefns.c (tzlookup, lisp_time_hz_ticks) (decode_time_components, lisp_to_timespec, lispint_arith) (time_arith, time_cmp, Fdecode_time, Fencode_time) (Ftime_convert): Prefer BASE_EQ to EQ where either will do.
Diffstat (limited to 'src/timefns.c')
-rw-r--r--src/timefns.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/timefns.c b/src/timefns.c
index 7d2e3f64143..6333e302ea5 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -212,7 +212,7 @@ tzlookup (Lisp_Object zone, bool settz)
212 212
213 if (NILP (zone)) 213 if (NILP (zone))
214 return local_tz; 214 return local_tz;
215 else if (EQ (zone, Qt) || EQ (zone, make_fixnum (0))) 215 else if (EQ (zone, Qt) || BASE_EQ (zone, make_fixnum (0)))
216 { 216 {
217 zone_string = "UTC0"; 217 zone_string = "UTC0";
218 new_tz = utc_tz; 218 new_tz = utc_tz;
@@ -516,7 +516,7 @@ lisp_time_hz_ticks (struct lisp_time t, Lisp_Object hz)
516 /* The idea is to return the floor of ((T.ticks * HZ) / T.hz). */ 516 /* The idea is to return the floor of ((T.ticks * HZ) / T.hz). */
517 517
518 /* For speed, just return T.ticks if T.hz == HZ. */ 518 /* For speed, just return T.ticks if T.hz == HZ. */
519 if (FASTER_TIMEFNS && EQ (t.hz, hz)) 519 if (FASTER_TIMEFNS && BASE_EQ (t.hz, hz))
520 return t.ticks; 520 return t.ticks;
521 521
522 /* Check HZ for validity. */ 522 /* Check HZ for validity. */
@@ -729,7 +729,7 @@ decode_time_components (enum timeform form,
729 729
730 case TIMEFORM_TICKS_HZ: 730 case TIMEFORM_TICKS_HZ:
731 if (INTEGERP (high) 731 if (INTEGERP (high)
732 && (!NILP (Fnatnump (low)) && !EQ (low, make_fixnum (0)))) 732 && (!NILP (Fnatnump (low)) && !BASE_EQ (low, make_fixnum (0))))
733 return decode_ticks_hz (high, low, result, dresult); 733 return decode_ticks_hz (high, low, result, dresult);
734 return EINVAL; 734 return EINVAL;
735 735
@@ -923,7 +923,7 @@ lisp_to_timespec (struct lisp_time t)
923 yielding quotient Q (tv_sec) and remainder NS (tv_nsec). 923 yielding quotient Q (tv_sec) and remainder NS (tv_nsec).
924 Return an invalid timespec if Q does not fit in time_t. 924 Return an invalid timespec if Q does not fit in time_t.
925 For speed, prefer fixnum arithmetic if it works. */ 925 For speed, prefer fixnum arithmetic if it works. */
926 if (FASTER_TIMEFNS && EQ (t.hz, timespec_hz)) 926 if (FASTER_TIMEFNS && BASE_EQ (t.hz, timespec_hz))
927 { 927 {
928 if (FIXNUMP (t.ticks)) 928 if (FIXNUMP (t.ticks))
929 { 929 {
@@ -942,7 +942,7 @@ lisp_to_timespec (struct lisp_time t)
942 else 942 else
943 ns = mpz_fdiv_q_ui (*q, *xbignum_val (t.ticks), TIMESPEC_HZ); 943 ns = mpz_fdiv_q_ui (*q, *xbignum_val (t.ticks), TIMESPEC_HZ);
944 } 944 }
945 else if (FASTER_TIMEFNS && EQ (t.hz, make_fixnum (1))) 945 else if (FASTER_TIMEFNS && BASE_EQ (t.hz, make_fixnum (1)))
946 { 946 {
947 ns = 0; 947 ns = 0;
948 if (FIXNUMP (t.ticks)) 948 if (FIXNUMP (t.ticks))
@@ -1043,7 +1043,7 @@ lispint_arith (Lisp_Object a, Lisp_Object b, bool subtract)
1043 1043
1044 if (FASTER_TIMEFNS && FIXNUMP (b)) 1044 if (FASTER_TIMEFNS && FIXNUMP (b))
1045 { 1045 {
1046 if (EQ (b, make_fixnum (0))) 1046 if (BASE_EQ (b, make_fixnum (0)))
1047 return a; 1047 return a;
1048 1048
1049 /* For speed, use EMACS_INT arithmetic if it will do. */ 1049 /* For speed, use EMACS_INT arithmetic if it will do. */
@@ -1090,14 +1090,14 @@ time_arith (Lisp_Object a, Lisp_Object b, bool subtract)
1090 quicker while we're at it. Compare here rather than earlier, to 1090 quicker while we're at it. Compare here rather than earlier, to
1091 handle NaNs and check formats. */ 1091 handle NaNs and check formats. */
1092 struct lisp_time tb; 1092 struct lisp_time tb;
1093 if (EQ (a, b)) 1093 if (BASE_EQ (a, b))
1094 bform = aform, tb = ta; 1094 bform = aform, tb = ta;
1095 else 1095 else
1096 tb = lisp_time_struct (b, &bform); 1096 tb = lisp_time_struct (b, &bform);
1097 1097
1098 Lisp_Object ticks, hz; 1098 Lisp_Object ticks, hz;
1099 1099
1100 if (FASTER_TIMEFNS && EQ (ta.hz, tb.hz)) 1100 if (FASTER_TIMEFNS && BASE_EQ (ta.hz, tb.hz))
1101 { 1101 {
1102 hz = ta.hz; 1102 hz = ta.hz;
1103 ticks = lispint_arith (ta.ticks, tb.ticks, subtract); 1103 ticks = lispint_arith (ta.ticks, tb.ticks, subtract);
@@ -1175,7 +1175,7 @@ time_arith (Lisp_Object a, Lisp_Object b, bool subtract)
1175 either input used (TICKS . HZ) form or the result can't be expressed 1175 either input used (TICKS . HZ) form or the result can't be expressed
1176 exactly in (HI LO US PS) form, otherwise the (HI LO US PS) form 1176 exactly in (HI LO US PS) form, otherwise the (HI LO US PS) form
1177 for backward compatibility. */ 1177 for backward compatibility. */
1178 return (EQ (hz, make_fixnum (1)) 1178 return (BASE_EQ (hz, make_fixnum (1))
1179 ? ticks 1179 ? ticks
1180 : (!current_time_list 1180 : (!current_time_list
1181 || aform == TIMEFORM_TICKS_HZ 1181 || aform == TIMEFORM_TICKS_HZ
@@ -1222,7 +1222,7 @@ time_cmp (Lisp_Object a, Lisp_Object b)
1222 while we're at it. Compare here rather than earlier, to handle 1222 while we're at it. Compare here rather than earlier, to handle
1223 NaNs. This means (time-equal-p X X) does not signal an error if 1223 NaNs. This means (time-equal-p X X) does not signal an error if
1224 X is not a valid time value, but that's OK. */ 1224 X is not a valid time value, but that's OK. */
1225 if (EQ (a, b)) 1225 if (BASE_EQ (a, b))
1226 return 0; 1226 return 0;
1227 1227
1228 /* Compare (ATICKS . AZ) to (BTICKS . BHZ) by comparing 1228 /* Compare (ATICKS . AZ) to (BTICKS . BHZ) by comparing
@@ -1231,7 +1231,7 @@ time_cmp (Lisp_Object a, Lisp_Object b)
1231 struct lisp_time tb = lisp_time_struct (b, 0); 1231 struct lisp_time tb = lisp_time_struct (b, 0);
1232 mpz_t const *za = bignum_integer (&mpz[0], ta.ticks); 1232 mpz_t const *za = bignum_integer (&mpz[0], ta.ticks);
1233 mpz_t const *zb = bignum_integer (&mpz[1], tb.ticks); 1233 mpz_t const *zb = bignum_integer (&mpz[1], tb.ticks);
1234 if (! (FASTER_TIMEFNS && EQ (ta.hz, tb.hz))) 1234 if (! (FASTER_TIMEFNS && BASE_EQ (ta.hz, tb.hz)))
1235 { 1235 {
1236 /* This could be sped up by looking at the signs, sizes, and 1236 /* This could be sped up by looking at the signs, sizes, and
1237 number of bits of the two sides; see how GMP does mpq_cmp. 1237 number of bits of the two sides; see how GMP does mpq_cmp.
@@ -1535,7 +1535,7 @@ usage: (decode-time &optional TIME ZONE FORM) */)
1535 1535
1536 /* Compute SEC from LOCAL_TM.tm_sec and HZ. */ 1536 /* Compute SEC from LOCAL_TM.tm_sec and HZ. */
1537 Lisp_Object hz = lt.hz, sec; 1537 Lisp_Object hz = lt.hz, sec;
1538 if (EQ (hz, make_fixnum (1)) || !EQ (form, Qt)) 1538 if (BASE_EQ (hz, make_fixnum (1)) || !EQ (form, Qt))
1539 sec = make_fixnum (local_tm.tm_sec); 1539 sec = make_fixnum (local_tm.tm_sec);
1540 else 1540 else
1541 { 1541 {
@@ -1685,7 +1685,7 @@ usage: (encode-time TIME &rest OBSOLESCENT-ARGUMENTS) */)
1685 struct lisp_time lt; 1685 struct lisp_time lt;
1686 decode_lisp_time (secarg, false, &lt, 0); 1686 decode_lisp_time (secarg, false, &lt, 0);
1687 Lisp_Object hz = lt.hz, sec, subsecticks; 1687 Lisp_Object hz = lt.hz, sec, subsecticks;
1688 if (FASTER_TIMEFNS && EQ (hz, make_fixnum (1))) 1688 if (FASTER_TIMEFNS && BASE_EQ (hz, make_fixnum (1)))
1689 { 1689 {
1690 sec = lt.ticks; 1690 sec = lt.ticks;
1691 subsecticks = make_fixnum (0); 1691 subsecticks = make_fixnum (0);
@@ -1715,7 +1715,7 @@ usage: (encode-time TIME &rest OBSOLESCENT-ARGUMENTS) */)
1715 if (tm.tm_wday < 0) 1715 if (tm.tm_wday < 0)
1716 time_error (mktime_errno); 1716 time_error (mktime_errno);
1717 1717
1718 if (EQ (hz, make_fixnum (1))) 1718 if (BASE_EQ (hz, make_fixnum (1)))
1719 return (current_time_list 1719 return (current_time_list
1720 ? list2 (hi_time (value), lo_time (value)) 1720 ? list2 (hi_time (value), lo_time (value))
1721 : INT_TO_INTEGER (value)); 1721 : INT_TO_INTEGER (value));
@@ -1755,7 +1755,7 @@ bits, and USEC and PSEC are the microsecond and picosecond counts. */)
1755 if (EQ (form, Qt)) 1755 if (EQ (form, Qt))
1756 form = t.hz; 1756 form = t.hz;
1757 if (FASTER_TIMEFNS 1757 if (FASTER_TIMEFNS
1758 && input_form == TIMEFORM_TICKS_HZ && EQ (form, XCDR (time))) 1758 && input_form == TIMEFORM_TICKS_HZ && BASE_EQ (form, XCDR (time)))
1759 return time; 1759 return time;
1760 return Fcons (lisp_time_hz_ticks (t, form), form); 1760 return Fcons (lisp_time_hz_ticks (t, form), form);
1761} 1761}