summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-03-16 17:01:57 +0100
committerMattias EngdegÄrd <mattiase@acm.org>2022-04-04 09:49:31 +0200
commit530f163a7f4f1f0ead119b8d3c3dd9fa882af9b2 (patch)
treeec3ea94eab8acd9dee73d3e0e21580d1611aea06 /src/fileio.c
parentf4833c88bbb3ca69f75e230a50bbd5edb4d5c00d (diff)
downloademacs-530f163a7f4f1f0ead119b8d3c3dd9fa882af9b2.tar.gz
Speed up comparisons between 2 fixnums
Since <, <=, > and >= have their own byte-ops, the corresponding functions are mostly used as arguments to higher-order functions. This optimisation is particularly beneficial for sorting, where the comparison function is time-critical. * src/data.c (Flss, Fgtr, Fleq, Fgeq): * src/fileio.c (Fcar_less_than_car): Fast path for calls with 2 fixnum arguments.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 5d66a93ac6a..c418036fc6e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5523,7 +5523,10 @@ DEFUN ("car-less-than-car", Fcar_less_than_car, Scar_less_than_car, 2, 2, 0,
doc: /* Return t if (car A) is numerically less than (car B). */)
(Lisp_Object a, Lisp_Object b)
{
- return arithcompare (Fcar (a), Fcar (b), ARITH_LESS);
+ Lisp_Object ca = Fcar (a), cb = Fcar (b);
+ if (FIXNUMP (ca) && FIXNUMP (cb))
+ return XFIXNUM (ca) < XFIXNUM (cb) ? Qt : Qnil;
+ return arithcompare (ca, cb, ARITH_LESS);
}
/* Build the complete list of annotations appropriate for writing out