]> git.eshelyaron.com Git - emacs.git/commitdiff
(add-to-list): Optimize if compare-fn is `eq' or `eql'.
authorKim F. Storm <storm@cua.dk>
Sun, 22 Oct 2006 22:32:53 +0000 (22:32 +0000)
committerKim F. Storm <storm@cua.dk>
Sun, 22 Oct 2006 22:32:53 +0000 (22:32 +0000)
(sit-for): If last command was a prefix arg, add the read-ahead
event to unread-command-events as (t . EVENT) so it will be added
to this-command-keys by read-key-sequence.

lisp/subr.el

index 1f874be60e0fbdbeba9ca208983b9d52262fbca5..957d098703f429d9799dfc889ac0826f48a585ed 100644 (file)
@@ -1100,13 +1100,19 @@ until a certain package is loaded, you should put the call to `add-to-list'
 into a hook function that will be run only after loading the package.
 `eval-after-load' provides one way to do this.  In some cases
 other hooks, such as major mode hooks, can do the job."
-  (if (if compare-fn
-         (let (present)
-           (dolist (elt (symbol-value list-var))
-             (if (funcall compare-fn element elt)
-                 (setq present t)))
-           present)
-       (member element (symbol-value list-var)))
+  (if (cond
+       ((eq compare-fn 'eq)
+       (memq element (symbol-value list-var)))
+       ((eq compare-fn 'eql)
+       (memql element (symbol-value list-var)))
+       (compare-fn
+       (let (present)
+         (dolist (elt (symbol-value list-var))
+           (if (funcall compare-fn element elt)
+               (setq present t)))
+         present))
+       (t
+       (member element (symbol-value list-var))))
       (symbol-value list-var)
     (set list-var
         (if append
@@ -1752,8 +1758,14 @@ floating point support.
     (or nodisp (redisplay))
     (let ((read (read-event nil nil seconds)))
       (or (null read)
-         (progn (push read unread-command-events)
-                nil))))))
+         (progn
+           ;; If last command was a prefix arg, e.g. C-u, push this event onto
+           ;; unread-command-events as (t . EVENT) so it will be added to
+           ;; this-command-keys by read-key-sequence.
+           (if (eq overriding-terminal-local-map universal-argument-map)
+               (setq read (cons t read)))
+           (push read unread-command-events)
+           nil))))))
 \f
 ;;; Atomic change groups.