From 8c71ef0f8edc91d2dc0b220447856cf656f33f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Fri, 29 Aug 2025 16:24:02 +0200 Subject: [PATCH] ; use modern sort calls in more places * lisp/emacs-lisp/regexp-opt.el (regexp-opt, regexp-opt-group): * lisp/emacs-lisp/rx.el (rx--parse-any): New-style calls, also faster. --- lisp/emacs-lisp/regexp-opt.el | 4 ++-- lisp/emacs-lisp/rx.el | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el index 6c2350e9548..3edaca78e32 100644 --- a/lisp/emacs-lisp/regexp-opt.el +++ b/lisp/emacs-lisp/regexp-opt.el @@ -140,7 +140,7 @@ usually more efficient than that of a simplified version: (open (cond ((stringp paren) paren) (paren "\\("))) (re (if strings (regexp-opt-group - (delete-dups (sort (copy-sequence strings) 'string-lessp)) + (delete-dups (sort strings)) (or open t) (not open)) ;; No strings: return an unmatchable regexp. (concat (or open "\\(?:") regexp-unmatchable "\\)")))) @@ -250,7 +250,7 @@ Merges keywords to avoid backtracking in Emacs's regexp matcher." (prefixes ;; Sorting is necessary in cases such as ("ad" "d"). (sort (mapcar (lambda (s) (substring s 0 n)) strings) - 'string-lessp))) + :in-place t))) (concat open-group (regexp-opt-group prefixes t t) (regexp-quote (nreverse xiffus)) diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index c512d42cd15..58f95c7d89a 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -581,7 +581,7 @@ a list of named character classes in the order they occur in BODY." (cons (rx--condense-intervals (sort (append conses (mapcan #'rx--string-to-intervals strings)) - #'car-less-than-car)) + :key #'car :in-place t)) (nreverse classes)))) (defun rx--generate-alt (negated intervals classes)