aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-09-25 15:41:30 +0000
committerGerd Moellmann2000-09-25 15:41:30 +0000
commit1bc20d83cb040a51cad08b49b9e81d534fca57a5 (patch)
tree5b343c1dfefd1b060eaab5d6a35860adaf0f4b7b
parentd8b4516f4d03ce794d1caff62558b92de622083d (diff)
downloademacs-1bc20d83cb040a51cad08b49b9e81d534fca57a5.tar.gz
emacs-1bc20d83cb040a51cad08b49b9e81d534fca57a5.zip
(byte-compile-defvar-or-defconst): Only cons onto
current-load-list in top-level forms. Else this leaks a cons cell every time a defun is called.
-rw-r--r--lisp/emacs-lisp/bytecomp.el45
1 files changed, 27 insertions, 18 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index f0f24213d17..800df042a78 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -10,7 +10,7 @@
10 10
11;;; This version incorporates changes up to version 2.10 of the 11;;; This version incorporates changes up to version 2.10 of the
12;;; Zawinski-Furuseth compiler. 12;;; Zawinski-Furuseth compiler.
13(defconst byte-compile-version "$Revision: 1.1 $") 13(defconst byte-compile-version "$Revision: 2.76 $")
14 14
15;; This file is part of GNU Emacs. 15;; This file is part of GNU Emacs.
16 16
@@ -3213,26 +3213,35 @@ If FORM is a lambda or a macro, byte-compile it as a function."
3213 3213
3214(defun byte-compile-defvar (form) 3214(defun byte-compile-defvar (form)
3215 ;; This is not used for file-level defvar/consts with doc strings. 3215 ;; This is not used for file-level defvar/consts with doc strings.
3216 (let ((var (nth 1 form)) 3216 (let ((fun (nth 0 form))
3217 (var (nth 1 form))
3217 (value (nth 2 form)) 3218 (value (nth 2 form))
3218 (string (nth 3 form))) 3219 (string (nth 3 form)))
3219 (if (memq 'free-vars byte-compile-warnings) 3220 (when (> (length form) 4)
3220 (setq byte-compile-bound-variables 3221 (byte-compile-warn
3221 (cons var byte-compile-bound-variables))) 3222 "%s %s called with %d arguments, but accepts only %s"
3223 fun var (length (cdr form)) 3))
3224 (when (memq 'free-vars byte-compile-warnings)
3225 (setq byte-compile-bound-variables
3226 (cons var byte-compile-bound-variables)))
3222 (byte-compile-body-do-effect 3227 (byte-compile-body-do-effect
3223 (list (if (cdr (cdr form)) 3228 (list
3224 (if (eq (car form) 'defconst) 3229 ;; Put the defined variable in this library's load-history entry
3225 (list 'setq var value) 3230 ;; just as a real defvar would, but only in top-level forms.
3226 (list 'or (list 'boundp (list 'quote var)) 3231 (when (null byte-compile-current-form)
3227 (list 'setq var value)))) 3232 `(push ',var current-load-list))
3228 ;; Put the defined variable in this library's load-history entry 3233 (when (> (length form) 3)
3229 ;; just as a real defvar would. 3234 (when (and string (not (stringp string)))
3230 (list 'setq 'current-load-list 3235 (byte-compile-warn "Third arg to %s %s is not a string: %s"
3231 (list 'cons (list 'quote var) 3236 fun var string))
3232 'current-load-list)) 3237 `(put ',var 'variable-documentation ,string))
3233 (if string 3238 (if (cdr (cdr form)) ; `value' provided
3234 (list 'put (list 'quote var) ''variable-documentation string)) 3239 (if (eq fun 'defconst)
3235 (list 'quote var))))) 3240 ;; `defconst' sets `var' unconditionally.
3241 `(setq ,var ,value)
3242 ;; `defvar' sets `var' only when unbound.
3243 `(if (not (boundp ',var)) (setq ,var ,value))))
3244 `',var))))
3236 3245
3237(defun byte-compile-autoload (form) 3246(defun byte-compile-autoload (form)
3238 (and (byte-compile-constp (nth 1 form)) 3247 (and (byte-compile-constp (nth 1 form))