emacs-diffs
[Top][All Lists]
Advanced

[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");
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]