From: David Kastrup <dak@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Adding rassq-delete-all to lisp/subr.el.
Date: Tue, 19 Apr 2005 18:39:06 +0200 [thread overview]
Message-ID: <854qe267rp.fsf@lola.goethe.zz> (raw)
In-Reply-To: <877jiy68hv.fsf@xs4all.nl> (Lute Kamstra's message of "Tue, 19 Apr 2005 18:23:24 +0200")
Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> writes:
> David Kastrup <dak@gnu.org> writes:
>
>> And I am not too fond of quadratic complexity algorithms.
>
> Me neither, but I was lazy and adapted assq-delete-all.
>
>> If one takes
>> (defun checkit ()
>> (setq x nil)
>> (dotimes (i 100001) (push (cons (- i) i) x))
>> (float-time
>> (time-since (prog1 (current-time)
>> (dotimes (i 101)
>> (setq x (rassq-delete-all (* 100 i) x)))))))
>>
>> The discrepancy seems pretty small after byte compilation, which seems
>> strange.
>
> delq in defined in C and it's only called 101 times.
Ah, right. If we removed all elements piecemeal, this would be
different.
>> What makes a _significant_ difference is using (car (cdr...)) instead
>> of (cadr...): for some unfathomable reason, cadr introduces a
>> temporary binding to "x", and that is really expensive in the inner
>> loop.
>
> Strange, (cadr ...) is just a defsubst for (car (cdr ...)). So
> compiled it should make no difference.
The defsubst binds and unbinds x. I consider that a byte compiler
deficiency.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
next prev parent reply other threads:[~2005-04-19 16:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-19 13:28 Adding rassq-delete-all to lisp/subr.el Lute Kamstra
2005-04-19 14:06 ` Lute Kamstra
2005-04-19 15:12 ` David Kastrup
2005-04-19 16:23 ` Lute Kamstra
2005-04-19 16:39 ` David Kastrup [this message]
2005-04-21 15:30 ` Richard Stallman
2005-04-21 17:33 ` Lute Kamstra
2005-04-19 22:27 ` Richard Stallman
2005-04-20 9:41 ` Lute Kamstra
2005-04-20 21:42 ` Richard Stallman
2005-04-20 23:23 ` Lute Kamstra
2005-04-21 15:30 ` Richard Stallman
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=854qe267rp.fsf@lola.goethe.zz \
--to=dak@gnu.org \
--cc=emacs-devel@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.