]> git.eshelyaron.com Git - emacs.git/commitdiff
lisp/subr.el (delete-dups): Avoid nreverse.
authorOleh Krehel <ohwoeowho@gmail.com>
Wed, 6 May 2015 19:30:54 +0000 (21:30 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Wed, 6 May 2015 19:30:54 +0000 (21:30 +0200)
lisp/subr.el

index a32fb968365b4c2c2476897b31f7316a3c2d66db..ce9b44c6ef9dc31a9697d3860154bd0b55660164 100644 (file)
@@ -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)))