diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2022-08-01 00:38:32 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2022-08-01 01:17:14 -0700 |
commit | 24e1123241b5692628de08e2de23448e07861111 (patch) | |
tree | 32132d19b056e483e74f4dd52a890647530cf738 /src/timefns.c | |
parent | 0a4477415c9df7d2cce8906155caadaa092b167e (diff) | |
download | emacs-24e1123241b5692628de08e2de23448e07861111.tar.gz |
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.
Diffstat (limited to 'src/timefns.c')
-rw-r--r-- | src/timefns.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/timefns.c b/src/timefns.c index 078e1f40fb8..990b23a5089 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); |