From 8e71dc6bac590753473f3cc5294d7b998bd156bc Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Mon, 13 Oct 2025 16:37:17 +0200 Subject: [PATCH] Use new 'sort' calling convention in json.el * lisp/json.el (json--print-alist): Use new 'sort' calling convention for simplicity and potential performance gains. --- lisp/json.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lisp/json.el b/lisp/json.el index f2086474a8b..82cc9c71bf5 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -609,12 +609,11 @@ transforms an unsortable MAP into a sortable alist." "Insert a JSON representation of ALIST at point. Sort ALIST first if `json-encoding-object-sort-predicate' is non-nil. Sorting can optionally be DESTRUCTIVE for speed." - (json--print-map (if (and json-encoding-object-sort-predicate alist) - (sort (if destructive alist (copy-sequence alist)) - (lambda (a b) - (funcall json-encoding-object-sort-predicate - (car a) (car b)))) - alist))) + (json--print-map (let ((pred json-encoding-object-sort-predicate)) + (if (and pred alist) + (sort alist :key #'car :lessp pred + :in-place destructive) + alist)))) ;; The following two are unused but useful to keep around due to the ;; inherent ambiguity of lists.