all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
Subject: Byte compiler inefficiency
Date: Sun, 07 Aug 2005 13:34:43 +0200	[thread overview]
Message-ID: <85acjuhtf0.fsf@lola.goethe.zz> (raw)


Hi, we have

(defsubst cadr (x)
  "Return the car of the cdr of X."
  (car (cdr x)))

And if we use that, for example, in

(defun woozle (blurb) (cadr blurb))

then the byte compiler delivers the result:

byte code for woozle:
  args: (blurb)
0	varref	  blurb
1	dup	  
2	varbind	  x
3	cdr	  
4	car	  
5	unbind	  1
6	return	  

The binding for x is completely unnecessary and wasteful.  FWIW, the
XEmacs byte compiler does not do this unnecessary binding.

I think that the byte compiler should be smart enough to remove
unnecessary bindings from defsubst stuff consisting purely of
side-effect free primitives and substitutions: those are not likely to
be advised, and if they are, one can still mark them as
non-side-effect free after the advice is activated.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

             reply	other threads:[~2005-08-07 11:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-07 11:34 David Kastrup [this message]
2005-08-08 12:09 ` Byte compiler inefficiency Richard M. Stallman
2005-08-08 12:20   ` David Kastrup
2005-08-09  2:43     ` Richard M. Stallman
2005-08-09  7:06       ` David Kastrup
2005-08-10  0:16 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85acjuhtf0.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.