[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 24e1123241 06/16: Improve time-equal-p etc. performance
From: |
Paul Eggert |
Subject: |
master 24e1123241 06/16: Improve time-equal-p etc. performance |
Date: |
Mon, 1 Aug 2022 04:17:27 -0400 (EDT) |
branch: master
commit 24e1123241b5692628de08e2de23448e07861111
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
Improve time-equal-p etc. performance
* src/timefns.c (time_cmp): Return EMACS_INT, not int; no need to
change callers. Compare (X . Z) to (Y . Z) quickly if X and Y are
fixnums.
---
src/timefns.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/timefns.c b/src/timefns.c
index 078e1f40fb..990b23a508 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -1192,7 +1192,7 @@ For example, nil stands for the current time. */)
/* Return negative, 0, positive if A < B, A == B, A > B respectively.
A and B should be Lisp time values. */
-static int
+static EMACS_INT
time_cmp (Lisp_Object a, Lisp_Object b)
{
/* Compare nil to nil correctly, and handle other eq values quicker
@@ -1201,6 +1201,12 @@ time_cmp (Lisp_Object a, Lisp_Object b)
if (BASE_EQ (a, b))
return 0;
+ /* Compare (X . Z) to (Y . Z) quickly if X and Y are fixnums.
+ Do not inspect Z, as it is OK to not signal if A and B are invalid. */
+ if (FASTER_TIMEFNS && CONSP (a) && CONSP (b) && BASE_EQ (XCDR (a), XCDR (b))
+ && FIXNUMP (XCAR (a)) && FIXNUMP (XCAR (b)))
+ return XFIXNUM (XCAR (a)) - XFIXNUM (XCAR (b));
+
/* Compare (ATICKS . AZ) to (BTICKS . BHZ) by comparing
ATICKS * BHZ to BTICKS * AHZ. */
struct lisp_time ta = lisp_time_struct (a, 0);
- master updated (ee0ce18662 -> bec8474a45), Paul Eggert, 2022/08/01
- master 24e1123241 06/16: Improve time-equal-p etc. performance,
Paul Eggert <=
- master 914cf4b91b 04/16: Make time arithmetic more like comparison, Paul Eggert, 2022/08/01
- master afa67ed6f2 08/16: Fix year-285428751 bug in hanoi-unix-64, Paul Eggert, 2022/08/01
- master 353413a76b 10/16: * lisp/vc/vc.el: Remove stray comment hyphen., Paul Eggert, 2022/08/01
- master 932c0bc1fc 01/16: Tune blv_found, Paul Eggert, 2022/08/01
- master d6c054a007 09/16: Fix "cons up a storm" issue in type-break, Paul Eggert, 2022/08/01
- master a51863f73d 12/16: Simplify a few timestamps, Paul Eggert, 2022/08/01
- master d634cb0954 11/16: Omit some (current-time) calls, Paul Eggert, 2022/08/01
- master 2cd204d8bb 13/16: Prefer ‘time-equal-p’ to ‘equal’ on timestamps, Paul Eggert, 2022/08/01
- master 72c3efd7d0 15/16: Fix time comparison in primitive-undo, Paul Eggert, 2022/08/01
- master bec8474a45 16/16: Improve GCC pacification in xterm.c, Paul Eggert, 2022/08/01