unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Byte compiler inefficiency
@ 2005-08-07 11:34 David Kastrup
  2005-08-08 12:09 ` Richard M. Stallman
  2005-08-10  0:16 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: David Kastrup @ 2005-08-07 11:34 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-08-10  0:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-07 11:34 Byte compiler inefficiency David Kastrup
2005-08-08 12:09 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).