aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2022-03-04 19:21:38 -0800
committerPaul Eggert2022-03-04 19:29:04 -0800
commitaf742bb3bbf37b844367e27fd598c6b0ae868d05 (patch)
tree3eda80c0ad9239f6e5a7211e138533fc2728b913 /src
parent58b5652f6bd605e441037a29e8abcb615e76bea8 (diff)
downloademacs-af742bb3bbf37b844367e27fd598c6b0ae868d05.tar.gz
emacs-af742bb3bbf37b844367e27fd598c6b0ae868d05.zip
Avoid unnecessary make_float in time arithmetic
* src/timefns.c (float_time): New function. (time_arith, Ffloat_time): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/timefns.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/timefns.c b/src/timefns.c
index f73c69149f7..795a6484ce9 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -879,6 +879,16 @@ decode_lisp_time (Lisp_Object specified_time, bool decode_secs_only,
879 return form; 879 return form;
880} 880}
881 881
882/* Convert a Lisp timestamp SPECIFIED_TIME to double.
883 Signal an error if unsuccessful. */
884static double
885float_time (Lisp_Object specified_time)
886{
887 double t;
888 decode_lisp_time (specified_time, false, 0, &t);
889 return t;
890}
891
882/* Convert Z to time_t, returning true if it fits. */ 892/* Convert Z to time_t, returning true if it fits. */
883static bool 893static bool
884mpz_time (mpz_t const z, time_t *t) 894mpz_time (mpz_t const z, time_t *t)
@@ -1068,7 +1078,7 @@ time_arith (Lisp_Object a, Lisp_Object b, bool subtract)
1068 if (FLOATP (a) && !isfinite (XFLOAT_DATA (a))) 1078 if (FLOATP (a) && !isfinite (XFLOAT_DATA (a)))
1069 { 1079 {
1070 double da = XFLOAT_DATA (a); 1080 double da = XFLOAT_DATA (a);
1071 double db = XFLOAT_DATA (Ffloat_time (b)); 1081 double db = float_time (b);
1072 return make_float (subtract ? da - db : da + db); 1082 return make_float (subtract ? da - db : da + db);
1073 } 1083 }
1074 enum timeform aform, bform; 1084 enum timeform aform, bform;
@@ -1264,9 +1274,7 @@ If precise time stamps are required, use either `encode-time',
1264or (if you need time as a string) `format-time-string'. */) 1274or (if you need time as a string) `format-time-string'. */)
1265 (Lisp_Object specified_time) 1275 (Lisp_Object specified_time)
1266{ 1276{
1267 double t; 1277 return make_float (float_time (specified_time));
1268 decode_lisp_time (specified_time, false, 0, &t);
1269 return make_float (t);
1270} 1278}
1271 1279
1272/* Write information into buffer S of size MAXSIZE, according to the 1280/* Write information into buffer S of size MAXSIZE, according to the