unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* "simplifications"
@ 2007-11-19 10:46 David Kastrup
  2007-11-19 10:56 ` "simplifications" Juanma Barranquero
                   ` (3 more replies)
  0 siblings, 4 replies; 26+ messages in thread
From: David Kastrup @ 2007-11-19 10:46 UTC (permalink / raw)
  To: emacs-devel; +Cc: lekktu


Hi, I've seen the following:

Author: Juanma Barranquero <lekktu@gmail.com>  2007-11-17 03:50:37
Committer: Juanma Barranquero <lekktu@gmail.com>  2007-11-17 03:50:37
Parent: 1797ed583c1d6224dbe93db681b112a9b0278358 ((backquote): Improve argument/docstring consistency.)
Child:  034e6631c9aab6db046645510214df80e67c29d4 (*** empty log message ***)
Branches: master, remotes/origin/master, remotes/origin/origin
Follows: merge-multi-tty-to-trunk
Precedes: 

    (ring-size, ring-p, ring-insert, ring-length, ring-empty-p): Use c[ad]dr.
    (ring-plus1): Use `1+'.
    (ring-minus1): Use `zerop'.
    (ring-remove): Use c[ad]dr.  Use `when'.
    (ring-copy): Use c[ad]dr.  Use `let', not `let*'.
    (ring-ref): Use `let', not `let*'.
    (ring-insert-at-beginning): Use c[ad]dr.  Doc fix.
    (ring-insert+extend): Use c[ad]dr.  Fix typo in docstring.
    (ring-member): Simplify.  Doc fix.
    (ring-convert-sequence-to-ring): Simplify.


Could people, before introducing such "optimizations", check the
bytecode?

(defun xxx (x) (cadr x))
generates
byte code for xxx:
  args: (x)
0	varref	  x
1	dup	  
2	varbind	  x
3	cdr	  
4	car	  
5	unbind	  1
6	return	  

while
(defun xxx (x) (car (cdr x)))
generates
byte code for xxx:
  args: (x)
0	varref	  x
1	cdr	  
2	car	  
3	return	  

The former is _quite_ less efficient, so it is not a hot idea to use
it for data access primitives like the ring functions.

Personally, I think that we should make the byte compiler optimize the
unnecessary binding away.  But until that is the case, please don't
gratuitously replace (car (cdr ...)) with (cadr ...).

-- 
David Kastrup

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

end of thread, other threads:[~2007-11-22  1:34 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-19 10:46 "simplifications" David Kastrup
2007-11-19 10:56 ` "simplifications" Juanma Barranquero
2007-11-19 15:11   ` "simplifications" Stefan Monnier
2007-11-19 15:19     ` "simplifications" David Kastrup
2007-11-19 15:39     ` "simplifications" Juanma Barranquero
2007-11-19 15:44       ` "simplifications" Stefan Monnier
2007-11-19 15:47         ` "simplifications" Juanma Barranquero
2007-11-19 15:58           ` "simplifications" Stefan Monnier
2007-11-19 16:08             ` "simplifications" Juanma Barranquero
2007-11-19 18:46               ` "simplifications" Stefan Monnier
2007-11-19 16:02         ` "simplifications" David Kastrup
2007-11-19 16:05           ` "simplifications" Juanma Barranquero
2007-11-20  3:59         ` "simplifications" Richard Stallman
2007-11-20 15:27           ` "simplifications" Stefan Monnier
2007-11-21 21:37             ` "simplifications" Stephen J. Turnbull
2007-11-21 21:52               ` "simplifications" David Kastrup
2007-11-22  1:34                 ` "simplifications" Stephen J. Turnbull
2007-11-19 11:02 ` "simplifications" Juanma Barranquero
2007-11-19 11:33 ` "simplifications" Miles Bader
2007-11-19 11:57   ` "simplifications" David Kastrup
2007-11-19 12:08     ` "simplifications" Juanma Barranquero
2007-11-19 12:21       ` "simplifications" David Kastrup
2007-11-19 12:32         ` "simplifications" Juanma Barranquero
2007-11-19 12:49           ` "simplifications" David Kastrup
2007-11-19 12:54             ` "simplifications" Juanma Barranquero
2007-11-20  3:59 ` "simplifications" Richard Stallman

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).