]> git.eshelyaron.com Git - emacs.git/commitdiff
* Improve `comp-normalize-valset' reproducibility (bug#48021)
authorAndrea Corallo <akrl@sdf.org>
Thu, 29 Apr 2021 18:56:26 +0000 (20:56 +0200)
committerAndrea Corallo <akrl@sdf.org>
Thu, 29 Apr 2021 19:07:07 +0000 (21:07 +0200)
* lisp/emacs-lisp/comp-cstr.el (comp-normalize-valset): Make
it more reproducible.

lisp/emacs-lisp/comp-cstr.el

index 73b78a3672d5e41873f8de1904d4602545a9b41a..3c5578217aa491a330db00f83c028a2f8277ed5e 100644 (file)
@@ -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."