changeset 72785:a384943e84d7

(pushnew): Use add-to-list when convenient.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Sep 2006 17:47:39 +0000
parents 3f19250c6e68
children ac14644e0699
files lisp/emacs-lisp/cl.el
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/cl.el	Sun Sep 10 17:45:42 2006 +0000
+++ b/lisp/emacs-lisp/cl.el	Sun Sep 10 17:47:39 2006 +0000
@@ -149,13 +149,20 @@
   (if (symbolp place) (list 'setq place (list 'cons x place))
     (list 'callf2 'cons x place)))
 
+(defvar pushnew-internal)
+
 (defmacro pushnew (x place &rest keys)
   "(pushnew X PLACE): insert X at the head of the list if not already there.
 Like (push X PLACE), except that the list is unmodified if X is `eql' to
 an element already on the list.
 \nKeywords supported:  :test :test-not :key
 \n(fn X PLACE [KEYWORD VALUE]...)"
-  (if (symbolp place) (list 'setq place (list* 'adjoin x place keys))
+  (if (symbolp place)
+      (if (null keys)
+	  `(let ((pushnew-internal ,place))
+	     (add-to-list 'pushnew-internal x nil 'eql)
+	     (setq ,place pushnew-internal))
+	(list 'setq place (list* 'adjoin x place keys)))
     (list* 'callf2 'adjoin x place keys)))
 
 (defun cl-set-elt (seq n val)