From: Gerd Moellmann <gerd@gnu.org>
Date: Mon, 11 Sep 2000 18:26:43 +0000 (+0000)
Subject: (byte-compile-defvar): Only cons onto
X-Git-Tag: emacs-pretest-21.0.90~1669
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cc0f95a474767a554832d03a23c3a9a7cba833e6;p=emacs.git

(byte-compile-defvar): Only cons onto
current-load-list in top-level forms.  Else this leaks a cons cell
every time a defun is called.
---

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 01244908d57..464f4de84db 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2000-09-11  Gerd Moellmann  <gerd@gnu.org>
+
+	* bytecomp.el (byte-compile-defvar): Only cons onto
+	current-load-list in top-level forms.  Else this leaks a cons cell
+	every time a defun is called.
+
 2000-09-11  Miles Bader  <miles@lsi.nec.co.jp>
 
 	* diff-mode.el (diff-apply-hunk): Function basically rewritten.
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index bdcb17cfa76..c58038ba2bb 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -10,7 +10,7 @@
 
 ;;; This version incorporates changes up to version 2.10 of the
 ;;; Zawinski-Furuseth compiler.
-(defconst byte-compile-version "$Revision: 2.73 $")
+(defconst byte-compile-version "$Revision: 1.1 $")
 
 ;; This file is part of GNU Emacs.
 
@@ -3220,19 +3220,16 @@ If FORM is a lambda or a macro, byte-compile it as a function."
 	(setq byte-compile-bound-variables
 	      (cons var byte-compile-bound-variables)))
     (byte-compile-body-do-effect
-     (list (if (cdr (cdr form))
-	       (if (eq (car form) 'defconst)
-		   (list 'setq var value)
-		 (list 'or (list 'boundp (list 'quote var))
-		       (list 'setq var value))))
-	   ;; Put the defined variable in this library's load-history entry
-	   ;; just as a real defvar would.
-	   (list 'setq 'current-load-list
-		 (list 'cons (list 'quote var)
-		       'current-load-list))
-	   (if string
-	       (list 'put (list 'quote var) ''variable-documentation string))
-	   (list 'quote var)))))
+     (list
+      ;; Just as a real defvar would, but only in top-level forms.
+      (when (null byte-compile-current-form)
+	`(push ',var current-load-list))
+      (when (and string (null byte-compile-current-form))
+	`(put ',var 'variable-documentation ,string))
+      (if (cdr (cdr form))
+	  (if (eq (car form) 'defconst)
+	      `(setq ,var ,value)
+	    `(if (boundp ',var) ',var (setq ,var ,value))))))))
 
 (defun byte-compile-autoload (form)
   (and (byte-compile-constp (nth 1 form))