summaryrefslogtreecommitdiff
path: root/src/timefns.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-06-15 23:08:03 -0500
committerPaul Eggert <eggert@cs.ucla.edu>2022-06-15 23:27:08 -0500
commit343482d641511b54aa0444791770b4ea70d27cc7 (patch)
treef3afc7ffb3366bedaed07b66c5e1b13eb851cd29 /src/timefns.c
parent9a2be29672b8569406777af24d60f0afabf8b52d (diff)
downloademacs-343482d641511b54aa0444791770b4ea70d27cc7.tar.gz
Streamline time decoding and conversion
* src/lisp.h (lisp_h_BASE2_EQ, BASE2_EQ): New macros and functions. * src/timefns.c (tzlookup, Fdecode_time): Use them. (Ftime_convert): Convert to symbol once, instead of many times.
Diffstat (limited to 'src/timefns.c')
-rw-r--r--src/timefns.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/timefns.c b/src/timefns.c
index 6333e302ea5..13a84f6b3ce 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -212,7 +212,7 @@ tzlookup (Lisp_Object zone, bool settz)
if (NILP (zone))
return local_tz;
- else if (EQ (zone, Qt) || BASE_EQ (zone, make_fixnum (0)))
+ else if (BASE_EQ (zone, make_fixnum (0)) || BASE2_EQ (zone, Qt))
{
zone_string = "UTC0";
new_tz = utc_tz;
@@ -221,7 +221,7 @@ tzlookup (Lisp_Object zone, bool settz)
{
bool plain_integer = FIXNUMP (zone);
- if (EQ (zone, Qwall))
+ if (BASE2_EQ (zone, Qwall))
zone_string = 0;
else if (STRINGP (zone))
zone_string = SSDATA (ENCODE_SYSTEM (zone));
@@ -729,7 +729,7 @@ decode_time_components (enum timeform form,
case TIMEFORM_TICKS_HZ:
if (INTEGERP (high)
- && (!NILP (Fnatnump (low)) && !BASE_EQ (low, make_fixnum (0))))
+ && !NILP (Fnatnump (low)) && !BASE_EQ (low, make_fixnum (0)))
return decode_ticks_hz (high, low, result, dresult);
return EINVAL;
@@ -1535,7 +1535,7 @@ usage: (decode-time &optional TIME ZONE FORM) */)
/* Compute SEC from LOCAL_TM.tm_sec and HZ. */
Lisp_Object hz = lt.hz, sec;
- if (BASE_EQ (hz, make_fixnum (1)) || !EQ (form, Qt))
+ if (BASE_EQ (hz, make_fixnum (1)) || !BASE2_EQ (form, Qt))
sec = make_fixnum (local_tm.tm_sec);
else
{
@@ -1748,11 +1748,13 @@ bits, and USEC and PSEC are the microsecond and picosecond counts. */)
enum timeform input_form = decode_lisp_time (time, false, &t, 0);
if (NILP (form))
form = current_time_list ? Qlist : Qt;
- if (EQ (form, Qlist))
+ if (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (form))
+ form = SYMBOL_WITH_POS_SYM (form);
+ if (BASE_EQ (form, Qlist))
return ticks_hz_list4 (t.ticks, t.hz);
- if (EQ (form, Qinteger))
+ if (BASE_EQ (form, Qinteger))
return FASTER_TIMEFNS && INTEGERP (time) ? time : lisp_time_seconds (t);
- if (EQ (form, Qt))
+ if (BASE_EQ (form, Qt))
form = t.hz;
if (FASTER_TIMEFNS
&& input_form == TIMEFORM_TICKS_HZ && BASE_EQ (form, XCDR (time)))