aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2022-08-14 13:48:11 -0700
committerPaul Eggert2022-08-14 13:49:33 -0700
commita64fe6f31987ca4a2c8ac6b96b97c6a440aeb2a2 (patch)
treeacc902c564168a2e239248e949fc6ba31cafea80
parent15aba5e64496414ec4659118f910516d2dc5e8b4 (diff)
downloademacs-a64fe6f31987ca4a2c8ac6b96b97c6a440aeb2a2.tar.gz
emacs-a64fe6f31987ca4a2c8ac6b96b97c6a440aeb2a2.zip
Improve timefns speed on integers
* src/timefns.c (decode_lisp_time) [FASTER_TIMEFNS]: Speed up when SPECIFIED_TIME is an integer. (time_cmp) [FASTER_TIMEFNS]: Speed up when comparing integers.
-rw-r--r--src/timefns.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/timefns.c b/src/timefns.c
index b9d9a4ed976..eed2edf1cc0 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -861,6 +861,11 @@ decode_lisp_time (Lisp_Object specified_time, bool decode_secs_only,
861 if (! INTEGERP (low)) 861 if (! INTEGERP (low))
862 form = TIMEFORM_INVALID; 862 form = TIMEFORM_INVALID;
863 } 863 }
864 else if (FASTER_TIMEFNS && INTEGERP (specified_time))
865 {
866 decode_ticks_hz (specified_time, make_fixnum (1), result, dresult);
867 return form;
868 }
864 else if (FLOATP (specified_time)) 869 else if (FLOATP (specified_time))
865 { 870 {
866 double d = XFLOAT_DATA (specified_time); 871 double d = XFLOAT_DATA (specified_time);
@@ -1206,10 +1211,16 @@ time_cmp (Lisp_Object a, Lisp_Object b)
1206 return 0; 1211 return 0;
1207 1212
1208 /* Compare (X . Z) to (Y . Z) quickly if X and Y are fixnums. 1213 /* Compare (X . Z) to (Y . Z) quickly if X and Y are fixnums.
1209 Do not inspect Z, as it is OK to not signal if A and B are invalid. */ 1214 Do not inspect Z, as it is OK to not signal if A and B are invalid.
1210 if (FASTER_TIMEFNS && CONSP (a) && CONSP (b) && BASE_EQ (XCDR (a), XCDR (b)) 1215 Also, compare X to Y quickly if X and Y are fixnums. */
1211 && FIXNUMP (XCAR (a)) && FIXNUMP (XCAR (b))) 1216 if (FASTER_TIMEFNS)
1212 return XFIXNUM (XCAR (a)) - XFIXNUM (XCAR (b)); 1217 {
1218 Lisp_Object x = a, y = b;
1219 if (CONSP (a) && CONSP (b) && BASE_EQ (XCDR (a), XCDR (b)))
1220 x = XCAR (a), y = XCAR (b);
1221 if (FIXNUMP (x) && FIXNUMP (y))
1222 return XFIXNUM (x) - XFIXNUM (y);
1223 }
1213 1224
1214 /* Compare (ATICKS . AZ) to (BTICKS . BHZ) by comparing 1225 /* Compare (ATICKS . AZ) to (BTICKS . BHZ) by comparing
1215 ATICKS * BHZ to BTICKS * AHZ. */ 1226 ATICKS * BHZ to BTICKS * AHZ. */