From: Kim F. Storm Date: Sun, 22 Oct 2006 22:32:53 +0000 (+0000) Subject: (add-to-list): Optimize if compare-fn is `eq' or `eql'. X-Git-Tag: emacs-pretest-22.0.90~40 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fb1a5d8a82d2a3bba1f66c1825e85540d625412d;p=emacs.git (add-to-list): Optimize if compare-fn is `eq' or `eql'. (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. --- diff --git a/lisp/subr.el b/lisp/subr.el index 1f874be60e0..957d098703f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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)))))) ;;; Atomic change groups.