summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp-cstr.el
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2021-04-29 20:56:26 +0200
committerAndrea Corallo <akrl@sdf.org>2021-04-29 21:07:07 +0200
commit39ebc2689b5475c31ff8a825b872be93bbf32602 (patch)
treedae1e2f8914a00c33cea9ea7b8d8d4cb8c48b370 /lisp/emacs-lisp/comp-cstr.el
parent68bf917896daa10601c3fdff172205e9aa06d155 (diff)
downloademacs-39ebc2689b5475c31ff8a825b872be93bbf32602.tar.gz
emacs-39ebc2689b5475c31ff8a825b872be93bbf32602.tar.bz2
emacs-39ebc2689b5475c31ff8a825b872be93bbf32602.zip
* Improve `comp-normalize-valset' reproducibility (bug#48021)
* lisp/emacs-lisp/comp-cstr.el (comp-normalize-valset): Make it more reproducible.
Diffstat (limited to 'lisp/emacs-lisp/comp-cstr.el')
-rw-r--r--lisp/emacs-lisp/comp-cstr.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 73b78a3672d..3c5578217aa 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -190,13 +190,18 @@ Return them as multiple value."
(defun comp-normalize-valset (valset)
"Sort and remove duplicates from VALSET then return it."
- (cl-remove-duplicates
- (cl-sort valset (lambda (x y)
- ;; We might want to use `sxhash-eql' for speed but
- ;; this is safer to keep tests stable.
- (< (sxhash-equal x)
- (sxhash-equal y))))
- :test #'eq))
+ (cl-sort (cl-remove-duplicates valset :test #'eq)
+ (lambda (x y)
+ (cond
+ ((and (symbolp x) (symbolp y))
+ (string< x y))
+ ((and (symbolp x) (not (symbolp y)))
+ t)
+ ((and (not (symbolp x)) (symbolp y))
+ nil)
+ (t
+ (< (sxhash-equal x)
+ (sxhash-equal y)))))))
(defun comp-union-valsets (&rest valsets)
"Union values present into VALSETS."