[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/sort-key 0ef023eabf4 4/7: sort: make :lessp default to `value-le
From: |
Mattias Engdegård |
Subject: |
scratch/sort-key 0ef023eabf4 4/7: sort: make :lessp default to `value-less-p` |
Date: |
Wed, 20 Mar 2024 14:55:00 -0400 (EDT) |
branch: scratch/sort-key
commit 0ef023eabf43642a91996ac5568dac2c7ff91b29
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
sort: make :lessp default to `value-less-p`
---
src/fns.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/fns.c b/src/fns.c
index 75da359a7c6..75be7e2b622 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2402,7 +2402,7 @@ arguments are defined:
:lessp FUNC -- FUNC is a function that takes two arguments and returns
non-nil if the first element should come before the second.
- This argument is mandatory.
+ If absent or nil, `value-less-p' is used.
:destructive BOOL -- if BOOL is non-nil, SEQ is sorted in-place. Otherwise,
a sorted copy of SEQ is returned; this is the default.
@@ -2445,9 +2445,10 @@ usage: (sort SEQ &key KEY LESSP DESTRUCTIVE REVERSE) */)
signal_error ("Invalid keyword argument", args[i]);
}
- /* FIXME: use value-less-p by default */
if (NILP (lessp))
- error ("Missing :lessp argument");
+ /* FIXME: normalise it as Qnil instead, and special-case it in tim_sort?
+ That would remove the funcall overhead for the common case. */
+ lessp = Qvalue_less_p;
/* FIXME: for lists it may be slightly faster to make the copy after
sorting? Measure. */
@@ -6924,4 +6925,5 @@ For best results this should end in a space. */);
DEFSYM (QClessp, ":lessp");
DEFSYM (QCdestructive, ":destructive");
DEFSYM (QCreverse, ":reverse");
+ DEFSYM (Qvalue_less_p, "value-less-p");
}
- branch scratch/sort-key created (now a12e41ab540), Mattias Engdegård, 2024/03/20
- scratch/sort-key c0dd5d38c74 2/7: sort: new keyword argument calling convention, Mattias Engdegård, 2024/03/20
- scratch/sort-key 8d60d8bbcfb 1/7: sort: add back timsort key function handling, Mattias Engdegård, 2024/03/20
- scratch/sort-key 0ef023eabf4 4/7: sort: make :lessp default to `value-less-p`,
Mattias Engdegård <=
- scratch/sort-key 2b1d4c33fd1 5/7: sort: add test for the keyword args, Mattias Engdegård, 2024/03/20
- scratch/sort-key 6d448cce870 6/7: value-less-p: add NEWS entry, Mattias Engdegård, 2024/03/20
- scratch/sort-key b0a32c899b4 3/7: Add value-less-p, Mattias Engdegård, 2024/03/20
- scratch/sort-key a12e41ab540 7/7: sort: add NEWS entry, Mattias Engdegård, 2024/03/20