From 1ca93e01841975dab67fbc0f4cb92aff94a654d7 Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Wed, 6 May 2015 21:30:54 +0200 Subject: [PATCH] lisp/subr.el (delete-dups): Avoid nreverse. --- lisp/subr.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index a32fb968365..ce9b44c6ef9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -419,12 +419,15 @@ Of several `equal' occurrences of an element in LIST, the first one is kept." (if (> (length list) 100) (let ((hash (make-hash-table :test #'equal)) - res) - (dolist (elt list) - (unless (gethash elt hash) - (puthash elt elt hash) - (push elt res))) - (setcdr list (cdr (nreverse res)))) + (tail list) + elt retail) + (puthash (car list) t hash) + (while (setq retail (cdr tail)) + (setq elt (car retail)) + (if (gethash elt hash) + (setcdr tail (cdr retail)) + (puthash elt t hash)) + (setq tail retail))) (let ((tail list)) (while tail (setcdr tail (delete (car tail) (cdr tail))) -- 2.39.5