unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: leo <leo@bella.local>
Subject: lisp performace question: how efficent are (long) list parameters?
Date: 11 Jan 2004 03:35:04 +1100	[thread overview]
Message-ID: <m2brpblq2v.fsf@bella.local> (raw)

hi there

just a little thing for a lisp beginner. i have written a function:

(defun first-free-position (positions)
  "returns the first free position in POSITIONS of all frames"
  (if positions
      (let ((list-of-frames (frame-list)))
        (if (frame-on-position (car positions) list-of-frames)
            (first-free-position (cdr positions))
          (car positions)))))

this function recomputes `(frame-list)' for every recursion. so i
thought to set `(frame-list)' to a variable which could be carried
through as parameter:

(defun first-free-position (positions all-frames)
  "returns the first free position in POSITIONS of all-frames."
  (if positions      
        (if (frame-on-position (car positions) all-frames)
            (first-free-position (cdr positions) all-frames)
          (car positions))))

called like `(first-free-position position-alist (frame-list))' this
version computes (frame-list) only once, but the list `all-frames' is
put every time on the parameter stack.

so, what is more effiecent?

cheers, leo

             reply	other threads:[~2004-01-10 16:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-10 16:35 leo [this message]
2004-01-10 16:50 ` lisp performace question: how efficent are (long) list parameters? Joe Casadonte
2004-01-10 16:53 ` David Kastrup
2004-01-28  8:05 ` Kai Grossjohann

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=m2brpblq2v.fsf@bella.local \
    --to=leo@bella.local \
    /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.
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).