summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kastrup <dak@gnu.org>2006-10-30 22:49:04 +0000
committerDavid Kastrup <dak@gnu.org>2006-10-30 22:49:04 +0000
commit2d1dd54d7daeb318aa6a50d7fc93d436c666fde0 (patch)
treeb99257f5c094b998fc14e56c1405e4d65cd7e483
parent5fb9c53c678be2bbfdf038eae7f80167014c8e87 (diff)
downloademacs-2d1dd54d7daeb318aa6a50d7fc93d436c666fde0.tar.gz
(add-to-list): Don't continue checking if a match has
been found.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/subr.el10
2 files changed, 10 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9be9e30590b..c1902d0a1a4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-30 David Kastrup <dak@gnu.org>
+
+ * subr.el (add-to-list): Don't continue checking if a match has
+ been found.
+
2006-10-30 Chong Yidong <cyd@stupidchicken.com>
* tutorial.el: Move defvars to avoid bytecomp warnings.
diff --git a/lisp/subr.el b/lisp/subr.el
index 43ecfd56108..cf09264e4b1 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1108,11 +1108,11 @@ other hooks, such as major mode hooks, can do the job."
((eq compare-fn 'eql)
(memql element (symbol-value list-var)))
(t
- (let (present)
- (dolist (elt (symbol-value list-var))
- (if (funcall compare-fn element elt)
- (setq present t)))
- present)))
+ (let ((lst (symbol-value list-var)))
+ (while (and lst
+ (not (funcall compare-fn element (car lst))))
+ (setq lst (cdr lst)))
+ lst)))
(symbol-value list-var)
(set list-var
(if append