From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: byte compiling defcustom Date: Fri, 16 Nov 2007 21:40:06 -0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1195278110 12848 80.91.229.12 (17 Nov 2007 05:41:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Nov 2007 05:41:50 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 17 06:41:54 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ItGRG-0004l5-Ar for ged-emacs-devel@m.gmane.org; Sat, 17 Nov 2007 06:41:54 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ItGR3-0003fb-IM for ged-emacs-devel@m.gmane.org; Sat, 17 Nov 2007 00:41:41 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ItGQR-0003Ox-Uu for emacs-devel@gnu.org; Sat, 17 Nov 2007 00:41:04 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ItGQQ-0003Nu-6r for emacs-devel@gnu.org; Sat, 17 Nov 2007 00:41:02 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ItGQP-0003Nl-VL for emacs-devel@gnu.org; Sat, 17 Nov 2007 00:41:02 -0500 Original-Received: from oogie-boogie.ics.uci.edu ([128.195.1.41]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ItGQL-00010d-Vz; Sat, 17 Nov 2007 00:40:58 -0500 Original-Received: from mothra.ics.uci.edu (mothra.ics.uci.edu [128.195.6.93]) by oogie-boogie.ics.uci.edu (8.13.6/8.13.6) with ESMTP id lAH5e6tl027414; Fri, 16 Nov 2007 21:40:06 -0800 (PST) Original-Lines: 31 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (score=-1.44, required 5, autolearn=disabled, ALL_TRUSTED -1.44) X-ICS-MailScanner-From: dann@ics.uci.edu X-detected-kernel: by monty-python.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83417 Archived-At: Stefan Monnier writes: > > (defvar foo (if (featurep 'xemacs) 'bar 'baz) "doc") > > (defcustom foo1 (if (featurep 'xemacs) 'bar 'baz) "doc") > > > > Are compiled to: > > > (defvar foo 'baz (#$ . 543)) > > (custom-declare-variable 'foo1 '(if (featurep 'xemacs) 'bar 'baz) '(#$ . 581)) > > > The initial value expression for defcustom is saved and gets > > recalculated later in some cases. So it cannot in general be > > optimized. > > He probably meant "compiled" as much as "optimized". > The same holds of keyword arguments to custom-declare-variable, by the way. > > > This particular simplification could be done even in defcustom, since > > (featurep 'xemacs) is effectively a constant. But why bother > > to implement that optimization? It works fine as it is now. > > The patch below implements the desired feature: it byte-compiles the > default-value-expression (first part of the hunk) as well as any > keyword arguments (second part of the hunk). Notice that the second > part actually simplifies the code. FWIW the size of a tar file containing all the elc files in emacs went from 29511680 to 29491200 after this patch. Not the best metric, but it shows that the patch has some impact. So I'd vote for checking it in.