From: Oleh Krehel Date: Wed, 6 May 2015 19:30:54 +0000 (+0200) Subject: lisp/subr.el (delete-dups): Avoid nreverse. X-Git-Tag: emacs-25.0.90~2175 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1ca93e01841975dab67fbc0f4cb92aff94a654d7;p=emacs.git lisp/subr.el (delete-dups): Avoid nreverse. --- 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)))