From 39ebc2689b5475c31ff8a825b872be93bbf32602 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 29 Apr 2021 20:56:26 +0200 Subject: [PATCH] * Improve `comp-normalize-valset' reproducibility (bug#48021) * lisp/emacs-lisp/comp-cstr.el (comp-normalize-valset): Make it more reproducible. --- lisp/emacs-lisp/comp-cstr.el | 19 ++++++++++++------- 1 file 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." -- 2.39.5